← Quiz: DOM and Events: all 10 questions
Quiz: DOM and Events · Question 1 of 10
Which method returns the FIRST element matching a CSS selector?
Which method returns the FIRST element matching a CSS selector?
- A.document.querySelector()
- B.document.querySelectorAll()
- C.document.getElementsByClassName()
- D.document.find()
Answer & explanation
Correct answer: document.querySelector()
querySelector returns the first match; querySelectorAll returns all.
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 →