简体   繁体   中英

addEventListener is not working on click

Clicking on a button does not seem to do any action,i could not figure out what is wrong.Please help me find the same.

 Menu.prototype._initToggleEvents = function() {
    var scope = this;
    this.toggle.addEventListener( "click", function() {
      (scope.menuPosition == "off") ? scope._toggleMenuOn() : scope._toggleMenuOff();
    });
  };

Here is the plunker example : https://plnkr.co/edit/6kd2ZWc1iLJ2q1OPiiIM?p=preview

好吧,我发现从错误的位置触发插件会导致addEventListener不被调用,在body标签关闭之前将脚本移动就可以解决问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM