jQuery off() Method

Last Updated:

jQuery off() Method

The jQuery off() method removes an event handler.

Example

HTML Editor
<!DOCTYPE html> <html lang="en-US"> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> </head> <body> <h1>jQuery off() Method</h1> <p>Try to click on this paragraph</p> <button>p off</button> <div>paragraph click : <strong>Enabled</strong></div> <script> $(document).ready(function(){ $("p").click(function(){ alert("You Clicked the Paragraph."); }); $("button").click(function(){ $("p").off("click"); $("strong").text("Disabled") }); }); </script> </body> </html>

Syntax

$(selector).off(events, selector, handler);

Parameter Values

Value Type Explanation
events Required Specifies one or more space-separated event types and optional namespaces, or just namespaces.
selector Optional A selector which should match the one originally passed to .on() when attaching event handlers.
handler Optional A handler function previously attached for the event(s), or the special value false.

Browser Support

Devicedesktopmobile
Browsergoogle chromesafarifirefoxinternet Exploreredgeoperagoogle chromesafarifirefoxedgeoperaandroid webviewsamsung internet
off()YesYesYesYesYesYesYesYesYesYesYesYesYes

Share this Page

Meet the Author