← Quiz: DOM and Events: all 10 questions
Quiz: DOM and Events · Question 9 of 10
A to-do list has 500 items, each with a delete button. Why attach one click listener to the list instead of 500 listene…
A to-do list has 500 items, each with a delete button. Why attach one click listener to the list instead of 500 listeners?
- A.Browsers allow only one listener per page
- B.Clicks bubble up to the list, so one listener handles all items, including ones added later
- C.Buttons cannot have listeners
- D.It makes the buttons larger
Answer & explanation
Correct answer: Clicks bubble up to the list, so one listener handles all items, including ones added later
This is event delegation; check event.target to see which item was clicked.
Can you get the rest right without peeking?
Take the timed Quiz: DOM and Events quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →