event.isPropagationStopped()

Returns whether event.stopPropagation() was ever called on this event object.

This event method is described in the W3C DOM Level 3 specification.

version added: 1.3
This method does not accept any arguments.
Examples:

Checks whether event.stopPropagation() was called

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>event.isPropagationStopped demo</title>
  <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
  
<button>click me</button>
<div id="stop-log"></div>
  
<script>
function propStopped( event ) {
  var msg = "";
  if ( event.isPropagationStopped() ) {
    msg = "called";
  } else {
    msg = "not called";
  }
  $( "#stop-log" ).append( "<div>" + msg + "</div>" );
}
  
$( "button" ).click(function(event) {
  propStopped( event );
  event.stopPropagation();
  propStopped( event );
});
</script>
  
</body>
</html>
doc_jQuery
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.