cancelBubble 特性为 事件 interface is a historical alias to Event.stopPropagation() 。把其值设为 true before returning from an event handler prevents propagation of the event. In later implementations, setting this to false does nothing. See 浏览器兼容性 了解细节。

句法

event.cancelBubble = bool;
var bool = event.cancelBubble;
					

A 布尔 .

范例

elem.onclick = function(event) {
  // Do cool things here
  event.cancelBubble = true;
}
					

规范

规范 状态 注释
DOM
The definition of 'cancelBubble' in that specification.
实时标准

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
cancelBubble Chrome Yes
Yes
Starting with Chrome 58 and Opera 45, setting this property to false does nothing, as per spec discussion .
Edge 12 Firefox 53
53
Prior to Firefox 53, this property was defined on the UIEvent interface. See bug 1298970 了解更多细节。
IE Yes Opera Yes
Yes
Starting with Chrome 58 and Opera 45, setting this property to false does nothing, as per spec discussion .
Safari Yes WebView Android Yes
Yes
Starting with Chrome 58 and Opera 45, setting this property to false does nothing, as per spec discussion .
Chrome Android Yes
Yes
Starting with Chrome 58 and Opera 45, setting this property to false does nothing, as per spec discussion .
Firefox Android 53
53
Prior to Firefox 53, this property was defined on the UIEvent interface. See bug 1298970 了解更多细节。
Opera Android Yes
Yes
Starting with Chrome 58 and Opera 45, setting this property to false does nothing, as per spec discussion .
Safari iOS Yes Samsung Internet Android Yes
Yes
Starting with Samsung Internet 7.0 and Opera 45, setting this property to false does nothing, as per spec discussion .

图例

完整支持

完整支持

见实现注意事项。

元数据

  • 最后修改: