🚨 Get Your Free NFT Certificate Mint by Completing the Web3 Exam! START NOW

Code has been added to clipboard!

Use stopImmediatePropagation to Prevent Event Handlers From Executing

Reading time 1 min
Published Jan 2, 2018
Updated Oct 10, 2019

stopImmediatePropagation: Main Tips

  • This method is used to stop immediate propagation and prevent other event handlers on the same element from executing.
  • It is simply written as event.stopImmediatePropagation() - there are no arguments to include.

event.stopImmediatePropagation Explained

The event.stopImmediatePropagation method doesn't allow other event handlers on the same element to be executed. It can also prevent bubbling up the DOM in the same way as event.stopPropagation method.

Look at the example below. You will see the method preventing the second click event from executing:

$("div").click((event) => {
   alert("Handler 1");
$("div").click((event) => {
   alert("Handler 2");

Note: check whether the event.stopimmediatepropagation() is applied with the event.isImmediatePropagationStopped method.