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.
Official answer available
Preview the opening of the answer, then unlock the full walkthrough.
Event bubbling is a mechanism in the DOM where events triggered on a specific element propagate, or 'bubble,' up through the element's ancestors in the hierarchy. This means that if you click on a button inside a form, the click event will first be fired on the button, then on the form it's contained within, and continue up the DOM tree until it reaches the document root, unless stopped.
The practicality of event bubbling is profound. It allows us to implement event delegation—a technique where we listen for events on a parent element instead of attaching event listeners to individual...
easy
medium
medium
hard
hard
hard