In-Depth Look at How Events Propagate in JavaScript

1 · · June 24, 2019, 9:21 p.m.
A lesser-known fact about JavaScript events is that they actually “propagate” to nearby HTML elements. Like throwing a pebble into a pond creates ripples on the surface of the water… Did you know? Events in JavaScript actually propagate to other HTML elements. Let’s start with a small example where we apply two separate click listeners: <div class="wood"> wood <div class="chuck"> chuck </div> </div> Applying the event listeners… document .querySelector('.wood') .addEventListener(...