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 trialScott Shanley
4,309 PointsLooking for some help here. Tried everything, and can't move on without an answer...
Not sure if I'm just confused by the wording here or if it's something really simple i'm just overlooking. Super frustrating since I can't just see the answer after getting it wrong a thousand times.
Scott Shanley
4,309 PointsBeen playing around with a bunch of different variations of the below.
let navigationLinks = document.getElementsByTagName('nav ul li');
let galleryLinks;
let footerImages;
1 Answer
Michael Hulet
47,913 PointsIt looks like you actually have the basic gist of this, but I see 2 issues:
- You have the right idea that the easiest thing to do here would be to reference the elements by a CSS selector, but the
getElementsByTagName
function only takes the name of a single kind of tag and returns an array of all elements of that tag in the page. In order to query the DOM using a CSS selector, you need to use thequerySelectorAll
function, which takes a CSS selector as an argument and returns an array of all elements matching that selector - You're selecting the wrong elements with your CSS selector. This step of the challenge asks you to select all links within the
nav
tag, but your selector targets all list items in an unordered list in thenav
tag. I know it's fairly counterintuitive, but in HTML, a link is actually represented by thea
tag
Once you take care of those 2 issues, I think you'll be on the right track for this challenge. Great job!
Scott Shanley
4,309 PointsGot it! Thank you for your help and quick response!
Michael Hulet
47,913 PointsMichael Hulet
47,913 PointsCould you post the code you've written so far here? It makes it a bit easier for us to help you out 🙂