Unbind the "all selector" in jquery -


how can unbind "all selector"?

i try $("*").unbind(); jquery unbinds $('#demo').click(function())}; too.


html

<div id="hv_t"></div>  <br /><br /><br /> <hr /> <br /><br /><br />  <div id="demo">demo</div>  <br /><br /><br />  <div id="unbindhover">unbindhover</div> 


js

$('#demo').click(function() {     alert('click'); });  $('#unbindhover').click(function() {     alert('unbind hover');     $("*").unbind(); });  $("*").hover( function (e)  {     $('#hv_t').append('+');  }, function () {    $('#hv_t').append('-');              }); 

demo http://jsfiddle.net/k4zqa/

to unbind specific event binding, specify event , handler in unbind method. hover method shortcut binding mouseenter , mouseleave events, it's need unbind:

$("*").hover(handleenter, handleleave);  function handleenter() {   $('#hv_t').append('+'); }  function handleleave() {   $('#hv_t').append('-'); }  $('#unbindhover').click(function() {   $("*").unbind('mouseenter', handleenter).unbind('mouseleave', handleleave); }); 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -