- 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
How to suppress jQuery event handling temporarily?
To suppress jQuery event handling temporarily, add a class to your element so that you can prevent further code from execution.
Example
You can try to run the following code to learn how to suppress jQuery event handling −
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $(element).click(function(e) { e.preventDefault(); // Check for fired class if ($(this).hasClass('fired') == false) { // Add fired class $(element).addClass('fired'); // Remove fired class $(element).removeClass('fired'); } }); }); </script> <style> .fired { font-size: 25px; color: green; } </style> </head> <body> <h1>This is a heading</h1> <p class="fired">This is a paragraph.</p> <p class="fired">This is second paragraph.</p> </body> </html>
- Related Articles
- What is an Event Handling and describe the components in Event Handling in Java?
- How to implement JavaFX event handling using lambda in Java?
- How to override jQuery event handlers?
- How to remove event handlers using jQuery?
- How to handle jQuery AJAX success event?
- How to suppress Matplotlib warning?
- How does jQuery event namespace works?
- How to handle a link click event using jQuery?
- How to handle a double click event using jQuery?
- How to debug JavaScript/jQuery event bindings with Firebug?
- How to return variable value from jQuery event function?
- How to submit a form using jQuery click event?
- How to suppress warnings in MySQL?
- How does jQuery Datepicker onchange event work?
- How to handle a mouse right click event using jQuery?

Advertisements