最新的Web開發教程
 

stopImmediatePropagation()事件方法

<事件對象

當一個按鈕點擊,執行第一個事件處理程序,從正在執行停止的事件處理程序的其餘部分:

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");
}
試一試»

定義和用法

所述stopImmediatePropagation()方法防止同一事件的其他收聽從被調用。


瀏覽器支持

在表中的數字規定,完全支持方法的第一個瀏覽器版本。

方法
stopImmediatePropagation() 9

句法

event .stopImmediatePropagation()

參數

沒有

技術細節

返回值: 無返回值
DOM版本: DOM Level 3的活動

<事件對象