JavaScript · Junior · Question 50 of 75

How do you find the first element with the card class on the page?

Explanation

querySelector accepts any CSS selector and returns the first element or null. querySelectorAll returns a static NodeList of all matches. getElementsByClassName takes the class name without a dot, and indexing starts at 0.

Further reading

Problem with a question

JavaScript · Junior · question 50

Test yourself

Take the JavaScript · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz