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
Nathan Nielson
3,864 PointsBuild an Interactive Website -> Introduction to jQuery -> Using jQuery to Select Elements
On the next line, use jQuery to select all list items (li) in an unordered list (ul) with the class of 'nav'?
Im stuck on this task, please help.
This is my current code
$("#container"); $("#nav ul li");
5 Answers
Andrew Whitfield
5,239 PointsHi Nathan,
What did you understand by 'class' of 'nav' (compare with 'id' of 'nav')?
Patrick Serrano
13,834 PointsBy using $(β#nav ul liβ); you are trying to select the<li> inside the <ul> inside the element with the id of nav. Instead you want to be selecting the <li> inside the <ul> with the class of nav.
James Barnett
39,199 Points@Nathan -
To add to @Patrick's excellent answer...
The HTML would look something like this:
<ul class="nav">
<li></li>
</ul>
Now ask yourself ... what is the CSS selector I would use to select all <li>s from the above markup?
Remember: You use a . to select a class, whereas you use # to select an id.
Eric Mentele
7,325 Points$(".nav li"); This is mine and it wont work. I also tried $(".nav > li"); and $(".nav ~ li");.
Eric Mentele
7,325 PointsNever mind I got it. That was tricky. I couldn't find a single time this occurred in my CSS project files.