Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


Help With Challenge

Can anyone help with this challenge:


Hey Douglas,

So on Task 1 of 1 :

// This gets the element with the "navigation" id from index.html and stores it inside a variable called "navigation"
var navigation = document.getElementById("navigation");   

// This gets the children (the <li> items) of that same navigation element and stores it another var
var listItems = navigation.children;

For Task 2 of 2 :

HINT : You need to use the querySelector() method. Here is an example :

element = baseElement.querySelector(selectors);

2 Answers

Jonathan Grieve
Jonathan Grieve
Treehouse Moderator 91,028 Points

Think about what the question is asking for.

It's talking about traversing which is moving between different elements in the document tree which is HTML tags in the DOM.

You want to be able to search for the children of an unordered list which is your listItems variable.

So turn this

var listItems = navigation;

into this

var listItems = navigation.children;
Sean T. Unwin
Sean T. Unwin
28,672 Points

To further illustrate this, it is discussed two videos prior to the challenge in question, starting at about 6:45 of the lesson on Traversing Elements with Children.

thanks to all for the great answers, sometimes it's hard to understand what the instructor is trying to teach me.......i only saw one option for best answer so i clicked it.