QuickDevGuide

Home › JavaScript

Events & Event Delegation — JavaScript

Browser interaction is event driven. addEventListener(type, handler, options) registers a handler; the handler receives an Event object. Propagation Events travel in three phases: capture (window → target), target, then bubble (target → window). Most handlers run in the bubble phase. Method / option Effect event.preventDefault() Stop the browser default (form submit, link navigation) event.stopPropagation() Stop the event travelling further { once: true } Remove the listener after the first call { passive: true } Promise not to call preventDefault — smoother scrolling { capture: true } Run during the capture phase { signal } Remove the listener when an AbortController aborts Event delegation Instead of a listener on every list item, attach one listener to the parent and use…

Key Takeaways