🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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?

  1. A.Browsers allow only one listener per page
  2. B.Clicks bubble up to the list, so one listener handles all items, including ones added later
  3. C.Buttons cannot have listeners
  4. 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 →