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

One of the first code challenges in the deep dive: "JavaScript foundations".

Hey guys. I don't know how to solve this. It tells me to use the css selector as a string for jQuery. The string is supposed to be a list item of an unordered list with the class of 'nav'. What would that string look like?

I've tried <code>$("nav ul li");</code> And <code>$(".nav:ul.li");</code> and various others, what do I do here?

Thanks in advance, Kristófer.

3 Answers

The key to this question is to understand that the <ul> element has a class of nav, in other words it's <ul class = "nav">.

So the HTML would look something like this:

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

Now ask yourself ... what is the CSS selector I would use to select all <li>s from the above markup?

Thanks James :) Just saw this now, I sorted it out awhile ago. :)

what about $('.nav ul li') or $('.nav > ul > li') you need to tell jquery to select class nav, otherwise it wont know what it is

Richard Lewis - Remember our goal on the forum is give help not answers, next time try giving an explanation and/or a hint instead.

Need more explanation on the distinction check this out.

Apologies, will bear that in mind next time

Richard Lewis - No apology needed :smile:

Learning how to answer questions well is as much part of the journey as learning how to ask them well.