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

Returning Elements Using CSS Selectors

https://teamtreehouse.com/library/javascript-and-the-dom-3/getting-a-handle-on-the-dom/return-elements-using-css-selectors

Once again I'm stumped; this time on the third objective in the above link. I keep getting error messages no matter what approach I use.

Here's the objective:

"Next, select all <a> elements inside the unordered list with the ID gallery and assign them to the variable galleryLinks."

This is my answer:

let footerImages = document.querySeletorAll('footer a');

Here's the error message:

"There was an error with your code: TypeError: 'undefined' is not a function (evaluating 'document.querySeletorAll('footer a')')"

What am I doing wrong?

2 Answers

Steven Parker
Steven Parker
231,007 Points

Yea, that error message isn't too helpful. And you were right that the target part of your descendent selector should be "a". But the function name should be spelled "querySelectorAll" (with a "c").

And for the container part "the unordered list with the ID gallery" would be "ul#gallery" (or just "#gallery" since IDs must always be unique) instead of "footer".

Your solution didn't work but (' footer img') did. Thanks for your help anyway.

Steven Parker
Steven Parker
231,007 Points

Looks like we got the tasks confused. The objective you listed above is for task 2 (which is the one my answer was for, but you must have already solved), yet apparently you were actually working on task 3 which has this objective instead:

"Finally, select all images inside the footer element and assign them to the variable footerImages."   :see_no_evil:

No, I was referring to the third task. I thought I made that clear. I figured out task two on my own but it doesn't really matter now. Once again, thanks for your help.