stopImmediatePropagation() Event Method - Javascript DOM

Javascript examples for DOM:Event


The stopImmediatePropagation() method can stop other listeners of the same event.



Return Value

No return value

When clicking on a button, execute the first event handler, and stop the rest of the event handlers.

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<button id="myBtn">Test</button>

function myFunction(event) {/* ww w  . j  a v  a 2  s .  co  m*/
    console.log("Hello World!");

function someOtherFunction() {
    console.log("I will not get to say Hello World");

var x = document.getElementById("myBtn");
x.addEventListener("click", myFunction);
x.addEventListener("click", someOtherFunction);


Related Tutorials