Home > Web Front-end > JS Tutorial > How to use jQuery unbind method

How to use jQuery unbind method

藏色散人
Release: 2020-11-30 11:01:01
Original
1841 people have browsed it

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)".

How to use jQuery unbind method

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)
Copy after login

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

elements:

$("button").click(function(){
$("p").unbind();
});
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template