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

Robert Leonardi
Robert Leonardi
17,151 Points

I 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
Robert Leonardi
17,151 Points

yeap. my stupid mistake ... tks

andren
andren
28,558 Points

Because 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.