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('-'); });
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
Post a Comment