Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Treehouse jQuery Challenge

How can one use jQuery to select list items from an unordered list that has a specific class? The exact question reads "On the next line, use jQuery to select all list items (li) in an unordered list (ul) with the class of 'nav'?"

I have tried several times on treehouse but it won't let me pass!

$(".nav ul li");
like image 207
Lewis Frost Avatar asked Nov 17 '12 19:11

Lewis Frost


2 Answers

Your selector $(".nav ul li") means some element with class nav has ul, if ul has class nav then try this.

$("ul.nav li");
like image 128
Adil Avatar answered Oct 28 '22 07:10

Adil


$('.nav').children('li') 

would be a faster way to do this.

like image 45
Alon Avatar answered Oct 28 '22 06:10

Alon