X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY ANGULAR XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

jQuery event.stopPropagation() Method

jQuery Event Methods jQuery Event Methods

Example

Stop the click event from bubbling to parent elements:

$("span").click(function(event){
  event.stopPropagation();
  alert("The span element was clicked.");
});
$("p").click(function(event){
  alert("The p element was clicked.");
});
$("div").click(function(){
  alert("The div element was clicked.");
});

Try it yourself »

Definition and Usage

The event.stopPropagation() method stops the bubbling of an event to parent elements, preventing any parent event handlers from being executed.

Tip: Use the event.isPropagationStopped() method to check whether this method was called for the event.


Syntax

event.stopPropagation()

Parameter Description
event Required. The event parameter comes from the event binding function


jQuery Event Methods jQuery Event Methods


Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates FREE Website Templates Free HTML Templates

SHARE THIS PAGE

facebook