Remove the click event for all <p> elements:
The off() method is most often used to remove event handlers attached with the on() method.
As of jQuery version 1.7, the off() method is the new replacement for the unbind(), die() and undelegate() methods. This method brings a lot of consistency to the API, and we recommend that you use this method, as it simplifies the jQuery code base.
Note: To remove specific event handlers, the selector string must match the one passed to the on() method, when the event handler was attached.
Tip: To attach an event that only runs once and then removes itself, use the one() method.
| Parameter | Description |
|---|---|
| event | Required. Specifies one or more events or namespaces to remove from the
selected element(s). Multiple event values are separated by a space. Must be a valid event |
| selector | Optional. A selector which should match the one originally passed to the on() method when attaching event handlers |
| function(eventObj) | Optional. Specifies the function to run when the event occurs |
| map | Specifies an event map ({event:function, event:function, ...}) containing one or more event to attach to the elements, and functions to run when the events occur |
Changing from unbind() to off()
How to use off() to achieve the same effect as unbind().
Changing from undelegate() to off()
How to use off() to achieve the same effect as undelegate().
Changing from die() to off()
How to use off() to achieve the same effect as die().
Remove all click event handlers, added with on()
How to remove all click event handlers for all <p> elements added with the on()
method.
Remove
one specific event
function added with on()
How to remove a specific function added with the on() method.
Remove
an event handler using an event object
How to remove an event handler after the event has been triggered a certain
number of times.
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.