Home > Article > Web Front-end > How to use jQuery unbind method
The jQuery unbind method is used to remove all or selected event handlers, or terminate the execution of a specified function when an event occurs. The syntax of this method is "$(selector).unbind(event, function,eventObj)".
The operating environment of this tutorial: Windows 7 system, jquery version 1.10.0. This method is suitable for all brands of computers.
Recommended: "jquery tutorial"
The unbind() method removes the event handler of the selected element.
This method can remove all or selected event handlers, or terminate the execution of the specified function when an event occurs.
This method can also unbind the event handler through the event object. This method is also used to unbind events within itself (such as deleting the event handler after the event has been triggered a certain number of times).
Note: If no parameters are specified, the unbind() method will remove all event handlers for the specified element.
Note: The unbind() method applies to any event handler added by jQuery.
Since jQuery version 1.7, the on() and off() methods are the preferred way to add and remove event handlers on elements.
Syntax
$(selector).unbind(event,function,eventObj)
Parameters
event Optional. Specifies one or more events to be removed from the element.
Separate multiple event values by spaces.
If only this parameter is specified, all functions bound to the specified event will be deleted.
function Optional. Specifies the name of the function to unbind the specified event from the element.
eventObj Optional. Specifies the removed event object to use. The eventObj parameter comes from the event binding function.
Example
Remove event handlers of all e388a4556c0f65e1904146cc1a846bee elements:
$("button").click(function(){ $("p").unbind(); });
For more programming-related knowledge, please visit: Programming Learning ! !
The above is the detailed content of How to use jQuery unbind method. For more information, please follow other related articles on the PHP Chinese website!