Join MDN and developers like you at Mozilla's View Source conference, 12-14 September in Berlin, Germany. Learn more at https://viewsourceconf.org

event.stopPropagation

阻止当前事件的进一步冒泡行为。

语法

event.stopPropagation(); 

例子

查看示例5: 事件冒泡 ,了解该方法以及事件冒泡机制的更多信息。

备注

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

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

规范

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

浏览器兼容性

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)

 

文档标签和贡献者

 此页面的贡献者: Ende93, AlexChao, teoli, ziyunfei
 最后编辑者: Ende93,