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

HTML Build 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'?

$(".nav ul li");

Not sure what is wrong here?

3 Answers

I believe ...

.nav ul would be:

<div class="nav">
    <ul>
        <li></li>
    </ul>
</div>

and ul.nav would be:

<ul class="nav">
    <li></li>
</ul>

so "use jQuery to select all list items (li) in an unordered list (ul) with the class of 'nav'?" will be:

$("ul.nav li");
Bella Ratmelia
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Bella Ratmelia
Front End Web Development Techdegree Graduate 28,947 Points
$(".nav ul li");

the above can be translated as "li inside ul that is inside class of 'nav'."

ul with the class of nav should look something like this:

$("ul.nav");

"li inside ul that is inside class of 'nav'" -- is that the same thing as ALL li inside ul, or only ONE li inside ul?

Also, what exactly is the difference in html between ul.nav and .nav ul?

<!code> <div class="nav"> <ul> </ul> </div>

VS. ''' <div class="nav ul"></div> '''