Behavior of removeEventListener

dom-events, javascript

Solution

`removeEventListener` takes 2 parameters, the event, and the function to remove. This should work:

document.getElementById("div1").removeEventListener("click", clickfn);

Also, the function you're executing is empty.

var clickfn = function(){  };

Problem

Please check the below code: ``` var clickfn = function(){ alert("clicked"); } document.getElementById("div1").addEventListener("click",clickfn,true); clickfn = function(){ }; document.getElementById("div1").removeEventListener("click"); ``` http://jsfiddle.net/qUtzL/4/ Why does the `removeEventListener` does not work?

Original source

Related problems