Explain Event Bubbling in JavaScript
Instruction: Describe what event bubbling is and how it works in the context of the DOM.
Context: This question tests the candidate's knowledge of DOM manipulation and event handling, crucial for interactive web applications.
Updated
Official answer available
Read the opening below, then unlock the full answer and practical guidance.
Event bubbling is the phase in which a bubbling event travels from its target toward ancestor nodes. For a typical click, capture listeners on ancestors run before the target's listeners; bubble listeners on ancestors run afterward. Not every event bubbles. event.target identifies the event's target as exposed to the listener, while event.currentTarget is the node whose listener is currently running. Shadow DOM can retarget events at component boundaries...
Related Questions
-
easy
-
medium
-
medium
-
hard
-
hard
-
hard