remove event listener js code example

Example 1: javascript remove event listener

var someEventHander=function(event){
	console.log("do something");
}

//add listener
document.getElementById("someid").addEventListener('click',someEventHander);

//remove listener 
document.getElementById("someid").removeEventListener('click',someEventHander);

Example 2: remove add event listener jquery

//Remove all event handlers from all paragraphs:

$( "p" ).off();

//Remove all delegated click handlers from all paragraphs:

$( "p" ).off( "click", "**" );

Example 3: removeeventlistener

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

Example 4: removeEventListener

target.removeEventListener(type, listener[, options]);
target.removeEventListener(type, listener[, useCapture]);