BitlystBitlyst
PostsSeriesTopicsAbout

Bitlyst

Short, diagram-first posts on JavaScript, React & Next.js. Follow via RSS or the newsletter.

© 2026 Mohsen Fallahnejad

PostsSeriesTopicsLinksAboutRSSGitHubX
Posts/javascript
Beginner1 min read

Event Bubbling vs Event Capturing in JavaScript

Understand how events travel through the DOM: bubbling (bottom-up) vs capturing (top-down) with simple examples and mental models.

Mohsen Fallahnejad

Mohsen Fallahnejad

Sep 13, 2025Discuss

When you click on an element inside nested elements, the event doesn’t just happen on that element — it travels through the DOM. There are two ways this can happen: capturing and bubbling.


1. Event Capturing (trickle down)#

  • The event starts at the top (document) and goes down through each parent until it reaches the target.
  • Analogy: a grandparent tells a message → parent → child.

2. Event Bubbling (bubble up)#

  • The event starts at the target element and then goes up through the parents until the root (document).
  • Analogy: bubbles rise from the bottom of a glass to the top.

3. Default in JavaScript#

  • By default, JavaScript uses bubbling.
  • To use capturing, pass true as the third parameter in addEventListener.
javascript
// Bubbling (default)
button.addEventListener("click", () => {
  console.log("Button clicked!");
});

// Capturing
div.addEventListener(
  "click",
  () => {
    console.log("DIV clicked during capturing!");
  },
  true // 👈 capturing enabled
);

4. Event Flow Order#

When you click the button:

  1. Capturing phase: document → body → div → button
  2. Target phase: the button itself
  3. Bubbling phase: button → div → body → document

5. Why does this matter?#

  • Capturing: less common, useful if you want to intercept early.
  • Bubbling: very common, great for event delegation (attach one listener to a parent instead of every child).

🧠 Quick Mental Model#

  • Capturing = trickle down (parent → child)
  • Bubbling = bubble up (child → parent)

⚡ That’s it! Now you know how events travel in JavaScript.

Filed under#javascript#events#dom#basics

Was this worth your time?

One tap tells me what to write more of.

Mohsen Fallahnejad

Written by

Mohsen Fallahnejad

Frontend engineer explaining JavaScript, React & Next.js internals in posts you can finish over coffee. More about me

X ↗GitHub ↗LinkedIn ↗
← OlderAsync vs Sync in JavaScriptNewer →MVVM, Micro‑Frontends, and Domain‑Driven Frontend — A Practical Guide

Start the discussion

Questions, corrections, a better approach? I read and reply to every comment.

Read next

Async vs Sync in JavaScript

Understand the difference between synchronous and asynchronous code in JavaScript with simple examples and analogies.

Sep 13, 20251 min read

The $4.35 Item That Was Charged $4.34

Why 0.1 + 0.2 !== 0.3 in JavaScript, how floating-point math drops a cent when converting dollars to cents, and why money should be stored as integers.

Nov 3, 20265 min read1

The Leaderboard Arrived Sorted. JavaScript Re-sorted It by User ID.

Why JavaScript object key order puts integer-like keys first in ascending order, how that silently reorders JSON from your API, and when to use an array or Map.

Nov 3, 20265 min read

Get new posts in your inbox

No spam. Unsubscribe any time.

1 min left
Discuss👍 React
👍