- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
jQuery off() Method
The off() method in jQuery is used to remove event handlers attached with the on() method.
Syntax
The syntax is as follows −
$(selector).off(event,selector,function(eventOb),map)
Above, the event parameter specifies one or more events or namespaces to remove from the selected element(s), function(eventOb) is the function to run when the event occurs. The map parameter is the event map.
Example
Let us now see an example to implement the jQuery off() method −
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("p").on("click", function(){ $(this).css("font-size", "1.5em"); }); $("button").click(function(){ $("p").off("click"); }); }); </script> </head> <body> <h2>Demo Heading</h2> <p>Click here to change the font size</p> <button>Remove</button> </body> </html>
Output
This will produce the following output −
Click on the text to change the font size −
Now, run the script again. Click “Remove” to remove the event handler. After removing, when you will click on “Change”, then the font size won’t change −
- Related Articles
- jQuery eq() method
- jQuery toggle() Method
- jQuery is() Method
- jQuery $.proxy() Method
- jQuery after() method
- jQuery before() Method
- jQuery children() method
- jQuery next() method
- jQuery nextAll() method
- jQuery attr() Method
- jQuery fadeIn() Method
- jQuery fadeTo() Method
- jQuery fadeToggle() Method
- jQuery outerHeight() Method
- jQuery outerWidth() Method

Advertisements