One click on your HTML carried down and back up the teacher’s board: every element has a capture and a bubble listener that can log or stop, and the replay…
Why it matters
This is the base of event delegation, the answer to "why does the button click also trigger the card’s handler", and of clicks that punch through a modal. Knowing capture vs bubble and what stopPropagation does gives you correct handlers, not guesswork.
The key idea
An event travels both ways: capture down, then bubble up
Common mistakes
Thinking a click only hits its element The event bubbles up through every ancestor, so the parent’s handler runs too. That is a feature (the basis of delegation), not a bug. If the parent must ignore it, check e.target.closest(…) there, or stopPropagation() in the child when nobody above needs it.
Too much stopPropagation It kills delegation and analytics above it. Use it sparingly; often what you want is preventDefault. Listeners that must always hear (analytics, click outside) go in the capture phase.
Mixing up target and currentTargettarget = what was clicked, fixed along the way; currentTarget = the owner of the running listener, it changes at every step. Watch both at each step above.
Try it in this playground
Click "Beli", then follow it to the end The order: document → card → button (down), then button → card → document (up). Both ways!
Turn every capture listener off, click again Only the way up is left: what a plain addEventListener hears.
Set stop on the card’s bubble The card still runs, document above it is cut off. Look at the skipped steps.
Set stop on the card’s capture, click the button Now the event stops on the way down: the button itself never gets the click.