- 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
What are Event Methods in jQuery?
Commonly used event methods include $(document).ready(), click(), dblclick() etc. There is a list of methods which can be called on an Event Object,
The following are some of the methods which can be called on an Event Object,
S.No | Method and Description |
1 | preventDefault() Prevents the browser from executing the default action. |
2 | isDefaultPrevented() Returns whether event.preventDefault() was ever called on this event object. |
3 | isPropagationStopped() Returns whether event.stopPropagation() was ever called on this event object. |
4 | stopImmediatePropagation() Stops the rest of the handlers from being executed. |
Let us see an example of stopPropagation() method. The stopPropagation() method stops the bubbling of an event to parent elements, preventing any parent handlers from being notified of the event.
Example
You can try to run the following code to learn how to work with event method stopPropagation() in jQuery −
<html> <head> <title>jQuery stopPropagation() method</title> <script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function() { $("div").click(function(event){ alert("This is : " + $(this).text()); // Comment the following to see the difference event.stopPropagation(); }); }); </script> <style> div { margin:10px; padding:12px; border:2px solid #666; width:160px; } </style> </head> <body> <p>Click on any box to see the effect:</p> <div id = "div1" style = "background-color:blue;"> OUTER BOX <div id = "div2" style = "background-color:red;"> INNER BOX </div> </div> </body> </html>
- Related Articles
- What are jQuery Event Helper Methods?
- What are event attributes in jQuery?
- What are jQuery string methods?
- What are the methods in jQuery to manipulate attributes?
- What are the methods used to provide effects in jQuery?
- What is an Event Object in jQuery?
- What is the difference between jQuery add() & jQuery append() methods in jQuery?
- What is the difference between Ajax and jQuery-Ajax methods in jQuery?
- jQuery lose focus event
- Can I wrap a JavaScript event in a jQuery event?
- What are event handlers in JavaScript?
- What is the jQuery Event for user pressing enter in a textbox?
- Which methods are used to set styles on selected elements in jQuery?
- What is the difference between $.closest() and $.parents() methods in jQuery?
- What is the difference between jQuery.offsetParent( ) and jQuery.parent() methods in jQuery?

Advertisements