Home >>jQuery Tutorial >jQuery event.stopImmediatePropagation() Method
jQuery event.stopImmediatePropagation() method in jQuery is used to stops the rest of the event handlers from being executed and stops the event from bubbling up the DOM tree.
Syntax:event.stopImmediatePropagation()
Parameter | Description |
---|---|
event | It is a required parameter and is used to specify the event parameter comes from the event binding function |
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(".box1").click(function(event){
alert("Event handler 1 executed");
event.stopImmediatePropagation();
});
$(".box1").click(function(event){
alert("Event handler 2 executed");
});
$(".box1").click(function(event){
alert("Event handler 3 executed");
});
});
</script>
</head>
<body>
<div class="box1" style="height:80px;width:80px;padding:8px;background-color:orange;">Click here !.</div>
<p>The click on the second and third event will not be executed due to event.stopImmediatePropagation() so, you can try to erase this method and see what happens.
</body>
</html>
The click on the second and third event will not be executed due to event.stopImmediatePropagation() so, you can try to erase this method and see what happens.