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
Meg Dooley7,321 Points
Practice selecting elements review challenge
I feel like I've tried every possible combination of selectors and i still can't get past the first challenge. Should I use the 'querySelectorAll' or am I supposed to amend the HTML document by adding a class or tag name?
Aakash Srivastava5,415 Points
Hey Meg Dooley , here is the code :
// This will first select the "nav" tag and then target all the "anchor" tag within it let navigationLinks = document.querySelectorAll('nav a'); // This will first select the "ul" tag with id "gallery" and then target all the "anchor" element within it let galleryLinks = document.querySelectorAll('#gallery a'); // This will first select the "footer" element and then target all the "img" element within it let footerImages = document.querySelectorAll('footer img');
Hope this helped :)
Victoria Aoka7,652 Points
For the first task, since the challenge requires that we select the links which are in the
nav element, you can use this:
let navigationLinks = document.querySelectorAll('nav a');
KRIS NIKOLAISEN54,938 Points
Here are some hints. But first review CSS Descendant Selector here
- You shouldn't modify the html.
- You should use querySelectorAll.
- Make sure you select links (a not li). A lot of people make that mistake on this challenge.