Use element.removeEventListener(type, listener, useCapture) Remember to use this on one element and give it the same parameters as for adding.
One excellent coding method would be to create a function that stores listener details in a variable, mimicking how setTimeout() works, and adding this to the element's prototype. Here is an example function.
HTMLElement.prototype.eventListener= function(type, func, capture){ if(typeof arguments[0]=="object"&&(!arguments[0].nodeType)){ return this.removeEventListener.apply(this,arguments[0]); } this.addEventListener(type, func, capture); return arguments; }
This will add a method to all HTML nodes that can already accept event lists, and allow that.
var a=element.eventListener('click', myFunction, false);
source share