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.

HTML Build an Interactive Website Introduction to jQuery Using jQuery to Select Elements

Introduction to jQuery code challenge

In the build an interactive website course on the second step of the challenge, the task is to select all the list elements (li) inside an unordered list (ul) with the class of '.nav'

I used this code and it didn't work

$( ".nav li" );

I have also tried a few other css selector methods and I still couldn't pass the challenge.

Could somebody please help explain why I am not passing the challenge? Thanks in advance

3 Answers

$("ul.nav li")

Just a little more specific

Ethan Lowry
Ethan Lowry
Courses Plus Student 7,323 Points

While what you have posted is valid CSS that will in fact select all list elements inside any element with a class of 'nav', it may be that the challenge wants you to specifically include the unordered list in your selector. Try what you have, but with the 'ul' element (with the nav class attached) added.

Thank you so much! I was confused because I thought I was calling on the right class. I wasn't specific enough