Please check the below code:
var clickfn = function(){
alert("clicked");
}
document.getElementById("div1").addEventListener("click",clickfn,true);
clickfn = function(){ };
document.getElementById("div1").removeEventListener("click");
Why does the removeEventListener does not work?
removeEventListenertakes 2 parameters, the event, and the function to remove.This should work:
Also, the function you’re executing is empty.