The One with Event Propagation and e.preventDefault() — PART 1

Photo by Henrik Dønnestad on Unsplash

Event Propagation in JavaScript

Child div wrapped in a parent div wrapped in another parent div
Child div wrapped in a parent div wrapped in another parent div
index.html
add a click handler for all three div tags : child, parent, grandparent div
add a click handler for all three div tags : child, parent, grandparent div
index.js

event.preventDefault

Put a preventDefault function call inside the click handler for the innermost child div
Put a preventDefault function call inside the click handler for the innermost child div
Use of preventDefault function

Stop event propagation

wandering through infinities of Space and Time and looking the world through small ambitious eyes behind prescription glasses

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store