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

How can I fetch data from a web server in an android application? -

Change php variable from jquery value using ajax (same page) -

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