Lewis Frost
Lewis Frost

Reputation: 557

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");

Upvotes: 6

Views: 4207

Answers (2)

Alon
Alon

Reputation: 879

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

would be a faster way to do this.

Upvotes: 1

Adil
Adil

Reputation: 148110

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

$("ul.nav li");

Upvotes: 12

Related Questions