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 trialCarel Du Plessis
Courses Plus Student 16,356 PointsI don't understand why my code is not working.
Challenge question
On line 3 of app.js, select all images in the footer element and assign them to footerImages.
let footerImgs = document.querySelector('footer'); let footerImages = footerImgs.querySelectorAll('a');
why can't I use document.querySelector('footer') to select the footer tag and then use footerImgs.querySelectorAll('a') to select all the links inside the footer.
Challenge question
On line 3 of app.js, select all images in the footer element and assign them to footerImages.
let footerImgs = document.querySelector('footer'); let footerImages = footerImgs.querySelectorAll('a');
second try
in the console when i run document.querySelector('footer > a');
the console prints: NodeList(2) [a, a]
i have already tried footerImages = document.querySelectorAll('footer > a')[0]; didn't work.
let footerImgs = document.querySelectorAll('footer > a'); let footerImages; for (let i = 0; i < footerImgs.length; i += 1){ footerImages[i] = document.querySelectorAll('footer > a')[i]; }
3 Answers
Steven Parker
231,269 PointsThe instructions say "select all images in the footer element and assign them to footerImages."
But your code is selecting all the links (a) in the footer element instead of the images (img).
Fix that, and your first try will work.
Gonzalo Torres del Fierro
Courses Plus Student 16,751 Pointslet footerImages = document.querySelectorAll('footer img');
Gonzalo Torres del Fierro
Courses Plus Student 16,751 PointsThis line will select all images in the footer element (whether they are direct descendants or not) and assign them to the variable footerImages
this is a Jenifer Nordel Solution share with me on Slack
Aakash Srivastav
Full Stack JavaScript Techdegree Student 11,638 PointsAakash Srivastav
Full Stack JavaScript Techdegree Student 11,638 PointsCan you please use markdown so that we can understand you code better .
Just surround your code with ' ``` ' ( triple backticks) Thanks