Remove all event handlers for all <p> elements:
The unbind() method removes event handlers from selected elements.
This method can remove all or selected event handlers, or stop specified functions from running when the event occurs.
This method can also unbind event handlers using an event object. This is used to unbind an event from within itself (like removing an 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 from the specified element.
Note: The unbind() method works on any event handler attached with jQuery.
As of jQuery version 1.7, the on() and off() methods are preferred to attach and remove event handlers on elements.
| Parameter | Description |
|---|---|
| event | Optional. Specifies one or more events to remove from the elements. Multiple event values are separated by space. If this is the only parameter specified, all functions bound to the specified event will be removed. |
| function | Optional. Specifies the name of the function to unbind from the specified event for the element |
| eventObj | Optional. Specifies the event object to remove to use. The
eventObj parameter comes from the event binding function |
Unbind a specific function
How to use the unbind() method to unbind a specific function from a specified event for an element.
Unbind an event handler using an event object
Specifies an event object to remove.
The perfect solution for professionals who need to balance work, family, and career building.
More than 10 000 certificates already issued!
The HTML Certificate documents your knowledge of HTML.
The HTML5 Certificate documents your knowledge of advanced HTML5.
The CSS Certificate documents your knowledge of advanced CSS.
The JavaScript Certificate documents your knowledge of JavaScript and HTML DOM.
The jQuery Certificate documents your knowledge of jQuery.
The XML Certificate documents your knowledge of XML, XML DOM and XSLT.
The ASP Certificate documents your knowledge of ASP, SQL, and ADO.
The PHP Certificate documents your knowledge of PHP and SQL (MySQL).
Your message has been sent to W3Schools.