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 Practice Selecting Elements

matt thurmond
matt thurmond
8,743 Points

Not sure how to answer this question since using multiple selectors wasn't covered.

Is there a clear overview of the different ways to use multiple selectors with the querySelectorAll method? I couldn't find one in this lesson or online.

This question asks for several things, like only selecting links within list items that have a certain ID. The lesson only really covered the ability to use one selector, i.e. querySelectorAll('#rainbow'), not multiple selectors.

1 Answer

Justin Horner
STAFF
Justin Horner
Treehouse Guest Teacher

Hello Matt,

Think of passing multiple selectors to querySelectorAll as you would when creating CSS rulesets where you may string together various parts to create a single selector (e.g., div.highlighted > p).

The MDN documentation for querySelectAll explains this well by describing the "selectors" parameter as

A DOMString containing one or more selectors to match against. This string must be a valid CSS selector string;...

I hope this helps. Please let me know if you have any other related questions. Happy coding 🙂