jQuery unbind()
Method
Example
Remove event handlers for all <p>
elements:
Definition and Usage
The unbind()
method removes event handlers from the selected elements.
This method can remove all or selected event handlers, or stop specified functions from running when the event occurs.
The method can also unbind event handlers using the event object. It is also used to unbind events from within itself (for example, removing an event handler after it has been triggered a certain number of times).
Note: If no parameters are specified, the unbind()
method removes all event handlers from the specified element.
Note: The unbind()
method works with any event handler added by jQuery.
Since jQuery version 1.7, the on() and off() methods are the preferred ways to add and remove event handlers on elements.
Syntax
Parameter | Description |
---|---|
event | Optional. Specifies one or more events to remove from the element. <br>Multiple event values are separated by spaces. <br>If only this parameter is specified, all functions bound to the specified event are removed. |
function | Optional. Specifies the function name to unbind from the specified event on the element. |
eventObj | Optional. Specifies the event object to use for removal. This eventObj parameter comes from the event binding function. |
More Examples
Unbind Event Handler Using Event Object