Event delegation and event propagation in JavaScript
1. Event propagation Event propagation is the way events travel through the DOM tree. There are two directions of propagation: Example of event propagation Let’s assume we have the following HTML: And we add two event listeners: If you click on #child, you will see in the console: This happens because the event bubbles (it […]
Read more