← 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 →- Q1. Which method returns the FIRST element matching a CSS selector?
- Q2. Why call event.preventDefault() in a form submit handler?
- Q3. Why is setting innerHTML from user input risky?
- Q4. Event delegation relies on which behaviour?
- Q5. Which event fires on every keystroke in a text input?
- Q6. What does document.querySelectorAll(".task") return?
- Q7. Which is the cleanest way to highlight a selected card from JavaScript?
- Q8. Which pair of methods creates a new <li and puts it at the end of a list?
- 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?
- Q10. Inside a click handler, what does event.target refer to?