Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript and the DOM (Retiring) Getting a Handle on the DOM DOM Selection - More Review

Angelica Islas
Angelica Islas
4,082 Points

How do I solve this problem?

How would you use querySelectorAll to obtain a reference to all elements in a document with the class student-info and assign it to the constant studentInfo?

const studentInfo = document.querySelectorAll('student-info');

1 Answer

Hi Angelica,

your code is nearly correct...

When you use querySelector or querySelectorAll you have to select the element the same way you select in css. Which means if you select an id you write document.querySelector("#id-name"), if you select a class you write document.querySelectorAll(".class-name") etc.

Notice the dot "." in front of the class name (just as when you select a class in css) - that's all you are missing.

Blessings from Berlin and happy java-scripting, Nils

PS: If my answer helped you or solved your issues, please upvote my answer and/or mark it as "Best answer" (so people browsing the community forum know your issue is solved)