🎙 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 1 of 10

Which method returns the FIRST element matching a CSS selector?

Which method returns the FIRST element matching a CSS selector?

  1. A.document.querySelector()
  2. B.document.querySelectorAll()
  3. C.document.getElementsByClassName()
  4. 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 →