remove event handler javascript code example

Example 1: removeeventlistener

//                             type         function
element.removeEventListener("mousedown", handleMouseDown)
// full type list available here: https://developer.mozilla.org/en-US/docs/Web/Events

Example 2: javascript remove event listener not working

var someEventHander=function(){
	console.log("do something");
}
var handlerCopy=someEventHandler.bind(var1,var2)
//add listener
document.getElementById("someid").addEventListener('click',handlerCopy,true);
//remove listener 
document.getElementById("someid").removeEventListener('click',handlerCopy,true);

Tags:

Java Example