What is stopImmediatePropagation() in jQuery?

stopImmediatePropagation() in jQuery

stopImmeidatePropagation() in jQuery is used to prevent other event handlers from being executed on the same element. Let’s see its syntax and example.

Syntax

eventObject.stopImmediatePropagation()

As you can see in the above syntax, this method does not take any argument. That is to say, It does not return any value.

Example

See the Pen by Code Topology (@codetopology) on CodePen.

For instance, there are 3 event handlers attached to the onClick event on p tag. However, only the first event handler will get executed.

In conclusion, you can use stopImmediatePropagation() in jQuery if you want to prioritize a specific event handler over other handlers.

Leave a Reply

Your email address will not be published. Required fields are marked *