unbind
UK ['ʌn'baɪnd] US [ʌnˈbaɪnd]
vt.Unbind, liberate
jquery unbind() method syntax
Function: 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 the event occurs. ubind() works with any event handler attached via jQuery.
Unbind event handlers and functions for elements: Specifies one or more event handlers to be removed from the specified element. If no parameters are specified, the unbind() method removes all event handlers for the specified element.
Syntax: $(selector).unbind(event,function
Parameters:
Parameter | Description |
event | Optional. Specify one or more events to delete elements, separated by spaces. Event value. If only this parameter is specified, all functions bound to the specified event will be deleted. |
function | Optional. Specifies the specified event from the element Unbinding function name. |
Use the Event object to unbind the event handler: Specifies the event object to be deleted. Used to itself Internal event unbinding (such as deleting event handlers after an event has been triggered a certain number of times). If no parameters are specified, the unbind() method will delete all event handlers for the specified element.
Syntax: $(selector).unbind(eventObj)
Parameters:
Parameter | Description |
eventObj | Optional. Specifies the event object to be used. This eventObj parameter comes from the event binding function. |
jquery unbind() method example
<html> <head> <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("p").click(function(){ $(this).slideToggle(); }); $("button").click(function(){ $("p").unbind(); }); }); </script> </head> <body> <p>这是一个段落。</p> <p>这是另一个段落。</p> <p>点击任何段落可以令其消失。包括本段落。</p> <button>删除 p 元素的事件处理器</button> </body> </html>
Click the "Run instance" button to view the online instance