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

JavaScript

Deleted User

Using jQuery to Select Elements/ Second Challenge

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

I've been spending a while on this question and I can't seem to get it right. I thought it was the code below, but I seem to be mistaken. Any suggestions?

$("ul li.nav"); 

7 Answers

Try this:

$("ul > li.nav");

There was a discussion about this when the forum was on the facebook page, but I can't seem to find it.

Deleted User

you are close, the question is stating that the ul has a class of nav so you would need to do $("ul.nav li");

Well that's kind of an ambiguously-worded question then :)

Andrew Chalkley
STAFF
Andrew Chalkley
Treehouse Guest Teacher

I promise I wasn't trying to cause confusion :)

No worries. I actually can't think of a much better way to word it either!

Regardless, the question and the answer are now here, hopefully searchable, for any future travelers :)

Deleted User

Perfect, thanks!

thanks, i was stock on this for awhile also .. :)