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

Jeremiah Manalo
Jeremiah Manalo
1,300 Points

How do I select a HTML links within a HTML nav element and assign to a const/let using Javascript?

Completing Javascript and the DOM, unsure how to finish last task.

1 Answer

Hi Jeremiah Manalo ,

The three questions for this task are asking you to select descendant elements. To do this you first need to use a CSS selector then the descendent elements e.g. img or a tags.

// Select Nav then all anchor elements
let navigationLinks = document.querySelectorAll("nav a");
// Select Gallery then all anchor elements
let galleryLinks = document.querySelectorAll("#gallery a");
// Select Footer then all image elements
let footerImages = document.querySelectorAll("footer img");