método de evento stopImmediatePropagation()
Ejemplo
Al hacer clic en un botón, ejecute el primer controlador de eventos y detenga la ejecución del resto de los controladores de eventos:
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");
}
Definición y uso
El método stopImmediatePropagation() evita que se llame a otros oyentes del mismo evento.
Compatibilidad con navegador
Los números en la tabla especifican la primera versión del navegador que soporta totalmente este método.
Method | |||||
---|---|---|---|---|---|
stopImmediatePropagation() | Yes | 9.0 | Yes | Yes | Yes |
Sintaxis
event.stopImmediatePropagation()
Parámetros
Ninguna |
Detalles técnicos
Valor devuelto: | Sin valor de retorno |
---|---|
Versión DOM: | Eventos de nivel 3 de DOM |