Javascript examples for DOM:Event
The stopImmediatePropagation() method can stop other listeners of the same event.
None
No return value
When clicking on a button, execute the first event handler, and stop the rest of the event handlers.
<!DOCTYPE html> <html> <body> <button id="myBtn">Test</button> <script> function myFunction(event) {/* ww w . j a v a 2 s . co m*/ console.log("Hello World!"); event.stopImmediatePropagation(); } 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); </script> </body> </html>