Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery event.stopPropagation() method

jQuery event.stopPropagation() method

jQuery event methods jQuery event methods

Example

Prevent the click event from bubbling up to the parent element:

$("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 »


Definition and Usage

The event.stopPropagation() method prevents the event from bubbling up to parent elements, preventing any parent event handlers from being executed.

**Tip:** Please use event.isPropagationStopped() method to check whether this method was called on the specified event.


Syntax

event

.stopPropagation()

Parameters Description
event Required.event The parameters come from the event binding function.

jQuery event methods jQuery event methods