Post-Image

How to unbind event handlers with jQuery

Posted on

In this really short tutorial I will show you how to unbind event handlers from a event in jQuery.

Let’s say we have a event handler called handleEvent and bound this to the click event of a button with the id clickme.

var handleEvent = function() {
 alert( "You've clicked me!" );
};
$( "#clickme" ).bind( "click", handleEvent );

If we now want to unbind this handler from the event we can use the jQuery unbind function.

$( "#clickme" ).unbind( "click", handleEvent );

And that’s it.

Leave a Reply