Es6 Class. This.addeventlistener
I am trying in a class to add an eventlistener but keep getting this error: 'TypeError: this.win.addEventListener is not a function' How can i solve this? Code: class Ui { cons
Solution 1:
jQuery instances do not have addEventListener
method. Use on
instead.
addListeners() {
this.win.on('resize', this.onResize);
}
Solution 2:
jQuery objects are collections, we need to get the first element of that colection:
this.win[0].addEventListener('resize', this.onResize);
Post a Comment for "Es6 Class. This.addeventlistener"