DOM Query Selector
Multiple Choice Easy
Question
What does document.querySelector(".btn") return?
Hint
querySelector returns one element, querySelectorAll returns all.
Explanation
querySelector returns the first matching element (or null if none found). To get all matches, use querySelectorAll which returns a NodeList. The argument is any valid CSS selector string. For ID lookups, getElementById is slightly faster but less flexible.
Related Resources
Related Lessons
- DOM Manipulation
Learn DOM manipulation.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.