Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery unbind() method

jQuery unbind() method

jQuery event methods jQuery event methods

Example

Remove all

The event handler of the element:

$("button").click(function(){

$("p").unbind();

});

Try it »


Definition and Usage

The unbind() method removes event handlers from the selected elements.

This method can remove all or selected event handlers, or stop a specified function from running when the event occurs.

This method can also unbind event handlers via the event object. It is also used to unbind events internally (for example, removing an event handler after the event 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,on() and off() This method is the preferred way to add and remove event handlers on elements.


Syntax

$(

selector

).unbind(

event,function,eventObj

)

Parameters Description
event Optional. Specifies one or more events to remove from the elements.
 由空格分隔多个事件值。       

 如果只规定了该参数,则会删除绑定到指定事件的所有函数。 |

| function | Optional. Specifies the name of the function 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

Unbinding a specified function
How to use the unbind() method to unbind a specified function from a specified event on an element.

Unbinding an event handler using the event object
Specifies the event object to remove.


jQuery event methods jQuery event methods