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

Mark Neill
Mark Neill
11,797 Points

Stuck on basic Code Challenge

Hi Guys

I'm stuck on the first code challenge on 'Building a Responsive Website'.

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

My wrong answers $("nav ul li"); $("nav li"); $(".nav ul li"); $(".nav li");

error message Bummer! Enter the string of the CSS selector for all li elements in a ul element with the class of 'nav'

Cheers

Mark Neill
Mark Neill
11,797 Points

Got it:

$("ul.nav li");

2 Answers

Jacob Miranda
Jacob Miranda
19,080 Points

I was looking for anyone who was having the same issue instead of posting twice... But I don't understand why that worked over the first thing? Could you or anyone explain why $("ul.nav li"); works over $(".nav ul li"); ?

I just don't want to forget or not understand that ^ and then keep making the mistake in future projects. Thanks in advance!

Hey Jacob, I was stuck on the same question. It is all about how the question was worded.

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

ul is the element that has a class of nav. Think of it as <ul class="nav>.