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!

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

5,111 Points

Does this exercise want me to select all the link elements or all the list elements within the nav element?

Does the exercise want me to select all the a element within the nav element or all the list elements? I feel like I skipped a video or something but I didn't! Did the teacher mention anything about selecting child elements in the video beside turning even/odd rows to grey? So confused.

// this is what the video used to select even row, but here it raised a syntax error
let navigationLinks = document.querySelectorAll('nav:a'); 

1 Answer

Dean Paterson
Dean Paterson
12,996 Points

It's asking for you to get all the links (a tags) inside the <nav> element nav:a isn't correct syntax... nav a:hover, nav a:odd etc is correct. To get 'a' inside 'nav' use 'nav a'

let navigationLinks = document.querySelectorAll('nav a');

Hope this helps