Event Propagation in JavaScript

Javascript 10 min min read Updated: Mar 09, 2026 Intermediate
Event Propagation in JavaScript
Intermediate Topic 8 of 15

In JavaScript, events occur when users interact with a webpage. For example, clicking a button, hovering over an element, or submitting a form triggers an event. When an event occurs on an element, it does not only affect that element — it can also affect its parent and child elements. This behavior is known as event propagation.

Event propagation defines how an event travels through the DOM tree when it is triggered. Understanding event propagation is important for managing event handling effectively in complex web applications.

What is Event Propagation?

Event propagation is the process by which an event moves through the DOM hierarchy after it is triggered on an element. The event can move upward or downward through the DOM tree depending on how it is handled.

Key Point: Event propagation controls how events travel through parent and child elements in the DOM.

Phases of Event Propagation

Event propagation occurs in three main phases:

  • Capturing Phase
  • Target Phase
  • Bubbling Phase

Capturing Phase

During the capturing phase, the event starts from the top of the DOM tree (the document object) and travels downward toward the target element.

This phase is rarely used in most JavaScript applications but can be useful in advanced event handling scenarios.

Target Phase

In the target phase, the event reaches the element that triggered the event. This is the element where the user interaction actually occurred.

Bubbling Phase

In the bubbling phase, the event travels upward from the target element to its parent elements until it reaches the root of the DOM.

This is the most commonly used phase in JavaScript event handling.

Key Point: By default, most JavaScript events follow the bubbling phase.

Example of Event Bubbling

javascript document.getElementById("child").addEventListener("click", function(){ console.log("Child element clicked"); }); document.getElementById("parent").addEventListener("click", function(){ console.log("Parent element clicked"); });
Output

Child element clicked

Parent element clicked

When the child element is clicked, the event first triggers on the child element and then bubbles up to the parent element.

Stopping Event Propagation

Sometimes developers may want to prevent the event from propagating to parent elements. This can be done using the stopPropagation() method.

javascript document.getElementById("child").addEventListener("click", function(event){ event.stopPropagation(); console.log("Child clicked only"); });
Output

Child clicked only

In this example, the event does not propagate to the parent element.

Why Event Propagation is Important

Understanding event propagation helps developers control how events behave in complex DOM structures. It allows developers to manage multiple event handlers and avoid unwanted event triggers.

This concept is especially useful when working with nested elements and building interactive user interfaces.

Conclusion

Event propagation describes how events travel through the DOM when triggered. It includes three phases: capturing, target, and bubbling.

By understanding event propagation and using methods like stopPropagation(), developers can manage event behavior effectively in JavaScript applications.

In the next tutorial, you will learn about Event Delegation in JavaScript, a powerful technique for handling events efficiently in dynamic web applications.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators