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

jquery for li in ul in class nav

$(".nav ul li"); whats the correct answer?

3 Answers

Maximiliane Quel
PLUS
Maximiliane Quel
Courses Plus Student 55,489 Points

you want to chose the unordered list with the class of nav = ul.nav and within that restriction the list items:

$('ul.nav li');
Eric Martz
Eric Martz
16,007 Points

Ack, I must have hit reply and started putting together an answer while you were posting your answer. Didn't mean to post right after you. Sorry for the duplication.

Maximiliane Quel
Maximiliane Quel
Courses Plus Student 55,489 Points

no worries. at least we are not contradicting each other ;0). site seems to be quite sluggish today, which doesn't help

Eric Martz
Eric Martz
16,007 Points

When selecting an element with a class name, you have to put it together. So all ul elements with the class nav would be ul.nav.

To get the li elements inside the ul with class nav just add it to the end: ul.nav li.

$('ul.nav li')

Thanks Eric and Maximiliane for quick reply!!!