events - Why doesnot removeEventListener work?? -


var mouselistener = button2.addeventlistener("mouseover", function (e) { count++; ... if(count > 5) button2.removeeventlistener("mouseover", mouselistener); }); 

i don't why code doesn't work??? how use removeeventlistener () in javascript?

the listener function passing in addeventlistener function.

var mouselistener = function (e) {     count++;     ...     if ( count > 5 ) {         button2.removeeventlistener("mouseover", mouselistener);     } }  button2.addeventlistener("mouseover", mouselistener); 

documentation:
https://developer.mozilla.org/en-us/docs/web/api/eventtarget/removeeventlistener


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -