jQuery | event.isPropagationStopped() Method

The event.isPropagationStopped() Method in jQuery is used to check whether the object event.stopPropagation() is called or not. If event.stopPropagation() is called then it returns true otherwise returns false.

Syntax:

event.isPropagationStopped()

Parameters: It contains single parameter event which is mandatory. This parameter comes from event binding function.

Example 1: This example uses event.isPropagationStopped() method to check event.stopPropagation() is called or not.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
      
<head>
    <script src=
    </script>
      
    <script>
        $(document).ready(function() {
            $("button").click(function(event) {
                event.stopPropagation();
                alert("Is event.stopPropagation() called: " 
                        +  event.isPropagationStopped());
            });
        });
    </script>
</head>
  
<body>
    <h1>
        jQuery event.isPropagationStopped() Method
    </h1>
      
    <p>
        click on button to check if the 
        event.stopPropagation() is called.
    </p>
      
    <button>Check</button>
</body>
  
</html>

chevron_right


Output:

  • Before Clicking the button:
  • After Clicking the button:

Example 2: This example uses event.isPropagationStopped() method to check event.stopPropagation() is called or not.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
      
<head>
    <title>
        event.isPropagationStopped method
    </title>
      
    <script src=
    </script>
</head>
  
<body>
    <h1>
        jQuery event.isPropagationStopped() Method
    </h1>
      
    <p
        click on button to check if the 
        event.stopPropagation() is called.
    </p>
      
    <button>Check</button>
      
    <div id="GFG"></div>
       
    <script>
        function propStopped( event ) {
            var msg = "";
              
            if ( event.isPropagationStopped() ) {
                msg = "True";
            
            else {
                msg = "False";
            }
              
            $( "#GFG" ).append( "<div>" + msg + "</div>" );
        }
           
        $( "button" ).click(function(event) {
            propStopped( event );
            propStopped( event );
            event.stopPropagation();
            propStopped( event );
        });
    </script>
</body>
  
</html>        

chevron_right


Output:

  • Before Clicking the button:
  • After Clicking the button:


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.