Javascript examples for jQuery Method and Property:event.stopImmediatePropagation
The event.stopImmediatePropagation() method stops the rest of the event handlers and stops the event bubbling.
Parameter | Require | Description |
---|---|---|
event | Required. | The event parameter comes from the event binding function |
The following code shows how to execute the first event handler, and stop the rest of the event handlers from being executed:
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("div").click(function(event){ console.log("Event handler 1 executed"); event.stopImmediatePropagation(); });//from w w w .ja va 2 s . c om $("div").click(function(event){ console.log("Event handler 2 executed"); }); $("div").click(function(event){ console.log("Event handler 3 executed"); }); }); </script> </head> <body> <div style="height:100px;width:300px;padding:10px;border:1px solid blue;background-color:lightblue;">Click on this div element.</div> </body> </html>