jQuery event.isPropagationStopped()

Introduction

Check if event.stopPropagation() was called:

View in separate window

<!DOCTYPE html>
<html>
<head>
<script 
 src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js">
</script>/*from   ww  w. j a v a2s  .c o m*/
<script>
$(document).ready(function(){
  $("div").click(function(event){
    event.stopPropagation();
    document.getElementById("demo").innerHTML = 
          "Was event.stopPropagation() called: " +  
          event.isPropagationStopped();
  });
});
</script>
</head>
<body>

<p id="demo"></p>
<div 
style="height:100px;width:300px;padding:10px;background-color:lightblue;">
Click on this div element.</div>

</body>
</html>

The event.isPropagationStopped() method checks whether event.stopPropagation() was called for the event.

This method returns true if event.stopPropagation() is called, and false if not.

event.isPropagationStopped()
Parameter OptionalDescription
event Required.The event parameter comes from the event binding function



PreviousNext

Related