Latest web development tutorials
 

stopImmediatePropagation() Event Method

< Event Object

Example

When clicking on a button, execute the first event handler, and stop the rest of the event handlers from being executed:

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

function myFunction(event) {
    alert ("Hello World!");
    event.stopImmediatePropagation();
}

// This function will not be executed
function someOtherFunction() {
    alert ("I will not get to say Hello World");
}
Try it Yourself »

Definition and Usage

The stopImmediatePropagation() method prevents other listeners of the same event from being called.


Browser Support

The numbers in the table specify the first browser version that fully supports the method.

Method
stopImmediatePropagation() Yes 9.0 Yes Yes Yes

Syntax

event.stopImmediatePropagation()

Parameters

None

Technical Details

Return Value: No return value
DOM Version: DOM Level 3 Events

< Event Object