🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← All topics

Quiz: DOM and Events: questions with answers

10 questions, each with the answer and a short explanation.

Take the timed quiz + get a certificate →
  1. Q1. Which method returns the FIRST element matching a CSS selector?
  2. Q2. Why call event.preventDefault() in a form submit handler?
  3. Q3. Why is setting innerHTML from user input risky?
  4. Q4. Event delegation relies on which behaviour?
  5. Q5. Which event fires on every keystroke in a text input?
  6. Q6. What does document.querySelectorAll(".task") return?
  7. Q7. Which is the cleanest way to highlight a selected card from JavaScript?
  8. Q8. Which pair of methods creates a new <li and puts it at the end of a list?
  9. Q9. A to-do list has 500 items, each with a delete button. Why attach one click listener to the list instead of 500 listeners?
  10. Q10. Inside a click handler, what does event.target refer to?