JavaScript JavaScript and the DOM Getting a Handle on the DOM Practice Selecting Elements

matt thurmond
matt thurmond
6,580 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 🙂