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.
Can you tell me why this isn't right? (Introduction to jQuery --> Using jQuery to Select Elements)
Question: "On the next line, use jQuery to select all list items (li) in an unordered list (ul) with the class of 'nav'?"
$("#container"); $("ul li .nav");
The reason your code doesn't work Alan is because that selector is selecting elements with the nav class name, inside a list item, inside an unordered list.
<ul> <li> <span class="nav"></span> </li> </ul>
If that was your code, the span element would be selected. But the nav class name should be on the unordered list, not inside the list item.
So this is the code you want:
James Barnett39,199 Points
The key to this question is to understand that the
<ul> element has a class of nav, in other words it's
<ul class = "nav">.
So the HTML would look something like this:
<ul class="nav"> <li></li> </ul>
Now ask youself ... what is the CSS selector I would use to select all
<li>s from the above markup?
Thank you both very much! That is crystal clear for me now.