- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
How to disable a particular jQuery event on a page?
To disable a particular jQuery event, use the jQuery off() method. You can try to run the following code to learn how to disable a particular jQuery event on a page −
Example
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("p").on("click", function(){ alert("You clicked it!"); }); $("button").click(function(){ $("p").off("click"); }); }); </script> </head> <body> <p>Click me</p> <p>Click above to generate an alert box. Click the below button to remove namespace, which won’t generate an alert box.</p> <button>Remove Event</button> </body> </html>
- Related Articles
- How can we ENABLE AND DISABLE a particular MySQL event?
- How to disable some jQuery global Ajax event handlers for a request?
- How to disable mouse event on certain elements using JavaScript?
- How to make a page redirect using jQuery?
- How to load a page in div using jQuery?
- How to check if event exists on element in jQuery?
- How to handle a link click event using jQuery?
- How to handle a double click event using jQuery?
- How to submit a form using jQuery click event?
- How to use multiple versions of jQuery on the same page?
- How to pass a jQuery event as a parameter in a method?
- How to disable right click using jQuery?
- How to disable/ enable checkbox with jQuery?
- Can I wrap a JavaScript event in a jQuery event?
- How to handle a mouse right click event using jQuery?

Advertisements