target vs currentTarget Playground

Click an element in your HTML tree and a note climbs from e.target to the teacher, the listener: read e.target, e.currentTarget or this now, later in a…

Why it matters

This is the heart of event delegation: one listener on a parent handles many children, including ones added later. Pick the wrong one of target/currentTarget, or use this in an arrow function, and the handler changes the wrong element or throws.

The key idea

target = what was clicked, currentTarget = where the listener is

Common mistakes

Try it in this playground