tadam logo
Did you find an error in the text?
Select this with mouse and press
Ctrl + Enter
Xhtml.co.il Check Spelling
Orphus system

event.isPropagationStopped()

event.isPropagationStopped()

Returns: Boolean

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

event.isPropagationStopped()

version added: 1.3

This property was introduced in W3C DOM Level 3 specification.

Example

Checks whether event.stopPropagation() was called

function propStopped(e) {
  var msg = "";
  if ( e.isPropagationStopped() ) {
    msg =  "called"
  } else {
    msg = "not called";
  }
  $("#stop-log").append( "<div>" + msg + "</div>" );
}

$("button").click(function(event) {
  propStopped(event);
  event.stopPropagation();
  propStopped(event);
});  

The output of the code above will be:

Full source

Checks whether event.stopPropagation() was called

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
                    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
   <script type="text/javascript" language="javascript">
     $(document).ready(function(){
      function propStopped(e) {
       var msg = "";
       if ( e.isPropagationStopped() ) {
          msg =  "called"
       } else {
          msg = "not called";
       }
       $("#stop-log").append( "<div>" + msg + "</div>" );
      }
      $("button").click(function(event) {
         propStopped(event);
         event.stopPropagation();
         propStopped(event);
      });       
     });
   </script>

</head>
<body>
  <button>click me</button>
  <div id="stop-log"></div>
</body>

</html>
Was this information helpful?
   

Comments