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
James Bryer
656 PointsHow to answer this??!
The question goes :On the next line, use jQuery to select all list items (li) in an unordered list (ul) with the class of 'nav"?
And i got this:
'$("#container"); $("#nav ul");
Do you guys know how to make this work?
3 Answers
Kevin Korte
28,149 PointsBranden's answer could/would work in the wild, but it won't pass as the quiz answer, since it's not what they are asking for. He also used the id selector for nav, when it says in the question that it is a class.
Break down the question they are asking.
We have list items (li) inside of an unordered list (ul) with a class of nav (.nav)
First off, '#' is an id selector; not a class selector. Our UL has a class, so we need to use a period instead.
So if our UL has a class, that selector looks something like 'ul.nav'.
Than we need to select our LI's within that ul.nav.
Put it all together, you get
$('ul.nav li');
James Bryer
656 Pointsthank you kevin!
Can i ask:
- what is a period
- What is the distinct difference between class and id?
Thanks :)
James Barnett
39,199 PointsJames Bryer - The purpose of this code challenge is to check if you have the prerequisite CSS knowledge as the Build an Interactive Website course is assumes you already know about CSS concepts like classes and ids. I'd recommend you follow along with the become a web designer track which will cover HTML, CSS & JavaScript before you get to this course.
Branden Morin
10,497 Pointsvar list_items = $("#nav ul").children();
This will select all children elements within your selector.
hope this helps :)