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

Gary Stevenson
Gary Stevenson
2,310 Points

Stuck on selecting descendents.

Hi,

I understand what we are expected to do here but I'm not sure of the technique necessary to perform the task.

The only time Guil has shown us how to select a descendent in this course so far is when he selected the ":nth-child". Im not sure of the syntax required to select the children of <nav> here. The text link in the description leads to midway through another course which hasnt come up on my track yet.

2 Answers

Hi Gary, here is detailed solution:

//Step #1 Target all links that are nested in a ul in the nav element
let navigationLinks = document.querySelectorAll("nav a");
//Step #2 Target all links inside the unordered list with gallery id
let galleryLinks = document.querySelectorAll("#gallery a");
//Step #3 Target all images in footer element
let footerImages = document.querySelectorAll("footer img");

If you want to learn more about descendant selectors, here is a link: https://www.sitepoint.com/descendant-selector-css-selector If this helped you understand better, do not forget you can mark the answer as best answer! Happy Coding!

Gary Stevenson
Gary Stevenson
2,310 Points

So after looking at the questions section it appears that many people are having this same issue.

It appears that we are being quizzed on something we haven't been taught yet.