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

General Discussion

Learning jQuery

I am just trying to learn query, the first challenge with using jQuery to target an id=container is easy.Now I am trying to target (li) elements in an (ul) with the class 'nav'. No matter how i write the code I cannot get it right. May someone please help I am sure that it is very simple but I cannot figure it out.

4 Answers

Lorne Cyr
Lorne Cyr
2,662 Points

I'm having the same problem. I assumed the code should be typed like this: $(".nav ul li");

Just based on the examples shown in the video, and from what I could find searching google for the answers. Any help here would be really appreciated. :)

EDIT: Nevermind lol I finally cracked it. :)

James Barnett
James Barnett
39,199 Points

Peaches - 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">

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

If you are unclear on how to do that, consider checking out the Learn HTML & CSS learning adventure.

John Locke
John Locke
15,479 Points

Extra hint: Classes and ids are an attribute of their elements, not descended from them.

Thanks so much for your responses I am going to try it again now .