LeBlaireau
LeBlaireau

Reputation: 17467

return sibling with index

I am trying to select a sibling of a ul by index. The user answers a question and if wrong the correct answer is highlighted.

My code goes up one level and tried to find the <li> by index

el.parent('ul').eq(2).addClass('correct');

What am I doing wrong?

Upvotes: 1

Views: 33

Answers (2)

Chetan
Chetan

Reputation: 955

el.parent('ul').children('li').eq(2).addClass('correct');

Upvotes: 1

GaAd
GaAd

Reputation: 145

$("#ulid li").eq(indexNumberHere).addClass('correct')

Upvotes: 1

Related Questions