阻止捕获和冒泡阶段中当前事件的进一步传播。

语法

event.stopPropagation(); 

例子

查看示例5: 事件传播 在示例一章中有关此方法和事件在DOM中传播的更详细示例。

备注

查看 DOM 规范 中关于事件流的解释。 ( DOM Level 3 事件草案 有案例可参考。)

preventDefault 是另外一个相关的方法,它可以阻止事件触发后默认动作的发生。

规范

规范 状态 说明
DOM4
Event.stopPropagation()
Obsolete  
Document Object Model (DOM) Level 3 Events Specification
Event.stopPropagation()
Obsolete  
Document Object Model (DOM) Level 2 Events Specification
Event.stopPropagation()
Obsolete 初始定义

浏览器兼容性

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 Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support (Yes) (Yes) 9 (Yes) (Yes)
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support (Yes) (Yes) ? (Yes) (Yes)

 

文档标签和贡献者

此页面的贡献者: xgqfrms-GitHub, e-cloud, Ende93, AlexChao, teoli, ziyunfei
最后编辑者: xgqfrms-GitHub,