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
Li Xia
4,671 Pointssyntax
Code challenge = use jQuery to select all list items (li) in an unordered list (ul) with the class of 'nav'?
my code of $(".nav ul li") isn't parsing, hints?
3 Answers
James Barnett
39,199 PointsThink of the CSS you would use to select against this markup:
<ul class = "nav">
<li></li>
</ul>
If you are having trouble coming up with that CSS, it's probably because you skipped over the CSS Foundations course. In that case I'd suggest you follow along with the Become a Web Designer learning adventure.
Li Xia
4,671 Pointscss = .nav ul li
So translate this to jquery would be $(".nav ul li"); right?
James Barnett
39,199 PointsYour selector is .nav ul li
What that translates to is ...
- Find any elements with a class of
nav - look inside find any
uls - then look inside and find any
lis.
However the problem with that CSS is there is no ul inside of the element with a class of nav, they are one and the same. The ul is the element with the class of nav.
Li Xia
4,671 Pointsif the ul is the element with class = nav, shouldn't the css be .nav li?
I tried that and it didn't work. Any other hints?