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

Help with jQuery code challenge

I am on the first code challenge for the Using jQuery.

1st question: Write how you'd use jQuery to select an element with id of 'container' Answer I put: $("#container"); and this was accepted as correct.

2nd question: use jQuery to select all list items (li) in an unordered list (ul) with the class of 'nav'? Answer I put: $(".nav ul li"); and it is telling me it is incorrect. I also tried

$("nav ul li"); $("li ul nav"); $("li ul .nav"); $("ul li nav"); $("ul li .nav");

Can someone please tell me where I am going wrong?

2 Answers

The ul has a class of nav. To select an element with a class you can do something like

$("element.class")

From there, select all the children of that element.class combination.

Thank you that worked!!!!

$("ul.nav li");