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 trialchasethurmond3
373 PointsI need help understanding use querySelectorAll to obtain a reference to all elements in a document with the class --?
I'm stumped and have watched the video over several times and reviewed my notes. What is this asking? I've tried the same methods they used in the video and none of them have worked.
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 = ___________
12 Answers
Steven Parker
231,007 Points
const studentInfo = document.querySelectorAll(".student-info");
Cam Brennan
12,350 Pointsit doesn't seem to like single quotes like this: document.querySelectorAll('.student-info'); it will only accept document.querySelectorAll(".student-info");
Mauricio Hernandez
7,208 PointsThank you, have a blessed day.
Shane Ashford
14,705 PointsI had the same issue. I followed exactly what Guil did in the video:
const studentInfo = document.querySelectorAll('student-info');
and it didn't pass, but the answer from @stevenparker worked just fine. Anyone know why this is the case?
Brooke Smart
10,763 PointsThe . class distinction is missing ('.student-info')
Jack Cummins
17,417 PointsIt’s because you used single quotes instead of double quotes also .
Mike Hatch
14,940 PointsI also made the mistake. It's the period before "student" that we're overlooking.
nathan goel
7,410 PointsI tried also with the single quote, should work as well I believe but not here...
Tyler Kesling
6,905 PointsI've tried both const studentInfo = document. querySelectorAll(".student-info"); const studentInfo = document. querySelectorAll('.student-info');
neither are passing today.
Roald Jurrian Kamman
Front End Web Development Techdegree Graduate 15,544 PointsGet someone from Treehouse dev team in here the parameters for success on this one are not accepting some solutions that should work.
dwayne chomyk
Courses Plus Student 8,719 PointsI am having the same issue??
ian truong
4,685 Pointswhat do we do ? document.querySelectorAll(".studentInfo"); does not work.
Sean Killeen
10,330 Pointsdocument.querySelectorAll(".student-info"); worked for me. I had similar issues with the single quotes, but this seems to require double quotes
aloenpocky
6,599 PointsHad issues with this one because I was answering the quiz on my tablet instead of my laptop. Steven's example is correct.
kathyvuong
9,299 PointsI think this could be help . const studentInfo = document.querySelectorAll('.student-info'); It works.
Raphel Banda
6,864 Pointsconst studentInfo = document.querySelectorAll('.student-info')
the above works well
Julieta Dalla Pozza
4,337 Pointsthanks! but why? in the video they dont specify that we need dots for classes and # for ids right?
Julieta Dalla Pozza
4,337 Pointsthanks! but why? in the video they dont specify that we need dots for classes and # for ids right?
chasethurmond3
373 Pointschasethurmond3
373 PointsI am really terrible with JS... Literally doing everything wrong. 3 y.o can probably out do me on this. Idk what it is about it that's so difficult.
THANK you.
Shane Ashford
14,705 PointsShane Ashford
14,705 PointsThanks so much!
nathan goel
7,410 Pointsnathan goel
7,410 PointsI did exactly the same, except the semi-column at the end...really treehouse, this is not critical. I would work with or without the ";"
Mauricio Hernandez
7,208 PointsMauricio Hernandez
7,208 PointsThank you and have a blessed day.