Table of Contents

DOM - Event Propagation (known as Event Bubbling)

About

event propagation is a mechanism in which an event is propagated to all its ascendant (ancestore).

Event bubbles or propagates up the DOM tree: it starts with where the event happened, and then goes up the DOM tree.

Example

Example with the click event

<div>
    <a href="#">Bubbles demo - click me</a>
</div>
document.querySelector('a').onclick = function(event) {
   event.preventDefault();
   console.log("The link was clicked");
   console.log('Does the onClick event bubbles ? '+event.bubbles);
}
document.querySelector('div').onclick = function(event) {
   console.log("The div was clicked showing that the event bubbles up");
}

Management

see

The bubbles read-only property of an Event indicates whether the event bubbles up through the DOM or not.

stop