cancelBubble 事件属性

定义和用法

cancelBubble 属性防止事件流冒泡到父元素。

提示:如需防止向上冒泡到父元素并向下被子元素捕获,请改用 stopPropagation() 方法。

实例

防止当前事件冒泡:

function func1(event) {
  alert("DIV 1");
  event.cancelBubble = true;
{}

Try it yourself

Syntax

event.cancelBubble = true|false

Parameter

No.

Technical Details

Return value: No return value
DOM Version: DOM Level 3 Events

Browser Support

The numbers in the table indicate the first browser version that fully supports the property.

Property Chrome IE Firefox Safari Opera
cancelBubble Support 9.0 Support Support Support