bubblesevent property
event object
Definition and Usage
The bubbles event property returns a Boolean value, returning true if the event is a bubbling type, otherwise returning false.
Event bubbling is divided into three phases, as follows:
- First, the capture phase. The event passes down the document tree from the Document object to the target node. If any of the target's ancestors have specifically registered capture event handlers, those handlers will run during the event propagation process.
- The second phase occurs at the target node itself. Appropriate event handlers directly registered on the target will run. This is similar to the event handling method provided by the Level 0 event model.
- Third, the bubbling phase. In this phase, the event will propagate upward from the target element, bubbling back up to the document hierarchy of the Document object.
Syntax
event.bubbles
Example
Example
The following example can detect whether the event that occurred is a bubbling event:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example(example.com)</title>
<script>
function myFunction(e){
alert(e.bubbles);
}
</script>
</head>
<body>
<p onclick="myFunction(event)">Click this paragraph. If the event is a bubbling event, an alert box will pop up.</p>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Example(example.com)</title>
<script>
function myFunction(e){
alert(e.bubbles);
}
</script>
</head>
<body>
<p onclick="myFunction(event)">Click this paragraph. If the event is a bubbling event, an alert box will pop up.</p>
</body>
</html>
Try it Yourself »
event object Other extensions