How to remove an event handler

Sometimes we need to stop a page element from handling an event it has been previously configured to respond to. To do this, we use the .unbind() method.

$("#mydiv").unbind("click");

If the unbind() method is called without any arguments, then ALL event handlers are removed from our matching elements. If an event type is specified (string value just like in the bind() method), then all handlers of that particular type are removed. If a handler function is passed as the second parameter, then only THAT handler function is unbound.

When assigning event handlers dynamically, using the .one() method helps, but can be simulated with

$("#mydiv").unbind("click").click( function () { alert("Hello"); } );

This would force only a single click handler.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Hi

Good info!!

thanks for info, How see all

thanks for info, How see all events in one window?
lemon detox

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.