未捕获的TypeError:无法设置属性“已禁用”javascript

时间:2017-11-29 14:56:27

标签: javascript

我一直在尝试向我的网站添加通知栏,这需要一些javascript代码,我添加了它,但我收到错误未被捕Typerror:

Uncaught TypeError: Cannot set property 'disabled' of null

我的代码是

<script src="js/classie.js"></script>
    <script src="js/notificationFx.js"></script>
    <script>
        (function() {
            var svgshape = document.getElementById( 'notification-shape' ),
                bttn = document.getElementById( 'notification-trigger' );

            // make sure..
            bttn.disabled = false;
            bttn.addEventListener( 'click', function() {
                // create the notification
                var notification = new NotificationFx({
                    wrapper : svgshape,
                    message : '<p>Test!</p>',
                    layout : 'other',
                    effect : 'loadingcircle',
                    ttl : 9000,
                    type : 'notice', // notice, warning or error
                    onClose : function() {
                        bttn.disabled = false;
                    }
                });

                // show the notification
                notification.show();

                // disable the button (for demo purposes only)
                this.disabled = true;
            } );
        })();

我怎样才能解决这个问题呢?

0 个答案:

没有答案