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 trialIsrael Baptiste
Courses Plus Student 4,147 PointsHelp please
How can I write this code
On the next line, use jQuery to select all list items (li) in an unordered list (ul) with the class of 'nav'?
$(".nav ul li"); it keep giving me red line please help
2 Answers
Elliott Frazier
Courses Plus Student 9,647 PointsI believe this is correct:
$("ul.nav li")
Bryan Zavestoski
12,475 PointsYou could use:
$("ul.nav li")
However, I believe it is preferable to use this:
$("ul.nav").find("li")
Someone who knows a little more about JQuery may need to weigh in on that, but I believe using the JQuery methods are faster than a long CSS selector.
James Barnett
39,199 PointsConsidering this question from step 2 of a code challenge, I'm not sure why you are giving away answers to code challenges.
In my experience cut & paste does little to aid in the learning process.
So instead I'd suggest try to determine what gaps the user has to understand the user has and pointing them in that direction?
Bryan Zavestoski
12,475 PointsMy mistake. I didn't realize this was from one of the code challenges, and I agree that cut and paste is generally not the best way to learn. I will try to be more aware of this in the future.
However, I hope that the tip of using find() and other DOM navigation methods was helpful.
James Barnett
39,199 PointsHowever, I hope that the tip of using find() and other DOM navigation methods was helpful.
That's actually great advice actually, I learned it recently in Code School's Try JQuery course
Israel Baptiste
Courses Plus Student 4,147 Pointsthank you for all your answers and your help , I did it by myself . I understand the code but I am a Haitian , My engllsh is not good enough . to understand those question . I finish all the Jquery track and Java script Track . on code Academy .
James Barnett
39,199 PointsI understand the code but I am a Haitian , My engllsh is not good enough . to understand those question .
That's an excellent point. People responding should make sure someone understands the question and not just provide the answer in the form of the code.
Israel Baptiste
Courses Plus Student 4,147 Points1000 % with you Mr. James Barnett