阻止呼叫此方法的當前事件,繼續執行捕獲傳遞或冒泡傳遞。

語法

event.stopPropagation();

示例

參見 Event Propagation 裡示例章節的示例五,以參閱有關 DOM 方法、還有事件傳遞的相關資訊。

備註

請參見 DOM 規範裡面有關事件流的詮釋(DOM Level 3 Events draft有插圖)。

preventDefault 是用來阻止事件預設行為的補充方法。

規範

規範 狀態 註解
DOM
The definition of 'Event.stopPropagation()' in that specification.
Living Standard
DOM4
The definition of 'Event.stopPropagation()' in that specification.
Obsolete  
Document Object Model (DOM) Level 2 Events Specification
The definition of 'Event.stopPropagation()' in that specification.
Obsolete Initial definition

瀏覽器相容性

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support (Yes) (Yes) (Yes) 9 (Yes) (Yes)
Feature Android Edge Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support (Yes) (Yes) (Yes) ? (Yes) (Yes)

文件標籤與貢獻者

此頁面的貢獻者: iigmir, jackblackevo
最近更新: iigmir,