javascript - send event when calling anonymous addEventListener function, then remove it -


so can add event listener , sent event this

(function(){  document.getelementbyid("submitbtn").addeventlistener("click", function(event){     pd(event);   }, false); }());  function pd(event){    event.preventdefault();   } 

since can't pass event parameter function want called on click, there way can event can use named function can remove listener? this seems related, doesn't seem concerned passing parameter event. or there way remove listeners element?

since using jquery, why not use .on , .off? example: jsfiddle

<a class="test">test click</a>  <script> $(".test").on("click", function(event){   console.log(event);   $(".test").off().text('click handler off'); }); </script> 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

keyboard - C++ GetAsyncKeyState alternative -

android - java.net.UnknownHostException(Unable to resolve host “URL”: No address associated with hostname) -