bubbles 事件属性

定义和用法

bubbles 事件属性返回布尔值,指示事件是否为冒泡事件。

事件冒泡将事件定向到其预期的目标,其工作原理如下:

  • 单击按钮并将事件定向到该按钮
  • 如果为该对象设置了事件处理程序,则触发该事件
  • 如果没有为该对象设置事件处理程序,则事件会向上冒泡(就像水中的气泡)到对象的父级
  • 事件从父级冒泡到父级,直到它被处理,或者直到它到达 document 对象为止。

实例

搞清楚特定事件是否能冒泡:

var x = event.bubbles;

亲自试一试

语法

event.bubbles

Technical details

Return value:

Boolean value indicating whether the specified event is a bubbling event.

Possible values:

  • true - Event can bubble through DOM
  • false - Event does not bubble
DOM version: DOM Level 2 Events

Browser support

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

Properties Chrome IE Firefox Safari Opera
bubbles Support 9.0 Support Support Support