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 trialRobert Leonardi
17,151 PointsI already tested in console and it worked. why bummer?
I answered
document.querySelectorAll('[class=studentInfo]');
Tested already in console and OK Why wrong?
2 Answers
Robert Leonardi
17,151 Pointsyeap. my stupid mistake ... tks
andren
28,558 PointsBecause while it technically works to use an attribute selector like that it's overkill for this task when you are simply selecting a class, it's also worth pointing out that you have a typo in the class name. The name should be student-info
not studentInfo
.
CSS has a selector entirely dedicated to selecting classes which is simpler and more appropriate for this task. To use the selector you simply place a dot before the class name like this:
document.querySelectorAll('.student-info');
That line will select all elements with a class of student-info
. CSS also has a dedicated id selector that works the same except you add a #
before the id name instead of a dot.
Edit: Added info about class name typo which I did not notice when first writing the post.