Latest web development tutorials

jQuery unbind () method

jQuery Event Methods jQuery Event Methods

Examples

Remove all <p> elements in the event handler:

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

try it"

Definition and Usage

unbind () method to remove the selected elements of the event handler.

This method can remove all or selected event handler, or when an event occurs to terminate the specified function operation.

The method may also through the event object to cancel the event handler bound. This method is also used for its own internal events unbind (such as when an event has been triggered a certain number of times, remove the event handler).

Note: If not specified parameters, the unbind () method deletes the specified elements all event handlers.

Note: unbind () method is applicable to any of the jQuery to add an event handler.

Since jQuery version 1.7 onwards, ON () and off () method is the preferred method for removing an event handler is added and the elements.


grammar

$(selector).unbind(event,function,eventObj)

参数 描述
event 可选。规定一个或多个要从元素上移除的事件。
由空格分隔多个事件值。
如果只规定了该参数,则会删除绑定到指定事件的所有函数。
function 可选。规定从元素上指定事件取消绑定的函数名称。
eventObj 可选。规定要使用的移除的 event 对象。这个 eventObj 参数来自事件绑定函数。


Examples

More examples

Unbind specified function
How to use the unbind () method from the specified event on the element unbind the specified function.

Use event objects unbind event handlers
Provisions event object to remove.


jQuery Event Methods jQuery Event Methods