Skip to content

event bubbling

Event bubbling is the way a DOM event, after firing on the element where it happened, travels up through that element’s ancestors and runs their listeners too, up to the document and the window.

Bubbling is the last of the three phases of event dispatch in the DOM. The event first travels down from the window to the target in the capture phase, then reaches the target, then bubbles back up. Listeners that addEventListener() adds to ancestors run in the bubbling phase unless their capture option is true.

Every listener along the way receives the same event object. Its .target property stays the element where the event started, while .currentTarget is the element whose listener is running. Calling .stopPropagation() in a listener keeps the event from reaching any further elements.

Most events bubble, but a few, such as focus and mouseenter, don’t. An event’s .bubbles property tells which kind it is.

Event bubbling is part of the WHATWG DOM Standard, not ECMAScript. Node.js implements EventTarget but has no tree of targets, so its events don’t bubble.

Example

Say a to-do list should mark an item as done when it’s clicked, including items added later. One listener on the list catches clicks from every item as they bubble up, a pattern called event delegation. The code needs a browser, so it isn’t run here:

Language: HTML
<ul id="todos">
  <li>Buy milk</li>
  <li>Call the bank</li>
</ul>
Language: JavaScript
const list = document.querySelector("#todos");

list.addEventListener("click", (event) => {
  if (event.target.matches("li")) {
    event.target.classList.toggle("done");
  }
  console.log(`${event.target.tagName} -> ${event.currentTarget.id}`);
});
// Clicking "Buy milk" toggles the item and logs "LI -> todos"

The click fires on the <li> first, which has no listener of its own, then bubbles up to the <ul>. There, event.target is the clicked item and event.currentTarget is the list, so one callback handles every item. An <li> appended later works with no extra setup.

To follow a click through every element it visits, click an item or the list below, and switch on the capture option or .stopPropagation() to see how the trip changes:

Interactive diagram — enable JavaScript to view.
A developer lifts a finished web page into a rack at the end of a clay assembly line with stations labeled HTML + CSS, JavaScript, React + TS, and Portfolio.

Tutorial

How to Become a Front-End Developer

Learn how to become a front-end developer in four stages, from HTML and CSS to the portfolio projects employers look for, and see what the job pays.

basics career frontend

Have a question about this? Mentor AI can show you examples, compare related terms, and point you to tutorials.


By Leodanis Pozo Ramos • Updated Nov. 24, 2026