Automatically unbind event handlers in JQuery
javascript, jquery
Solution
use the `unbind` method
$("jq selector").unbind('click');
If you want to remove all events associated with an element, Call unbind() with no argument and it will removes all handlers attached to the element(s):
$("jq selector").unbind();
Problem
Is it possible to say to JQuery, hey! unbind any event handlers before adding this one, without making an explicit call to unbind?. Something like ``` $("jq selector").click(function() { ...}, true); ``` Where true means I want to unbind all click handlers set to the element. I've came across this on various occasions and on some had strange behaviours due not unbinding event handlers first. Thanks.