Home › Forums › CSS › [Solved] Tricky :nth-child question › Re: [Solved] Tricky :nth-child question
November 18, 2010 at 8:23 am
#74757
Chris Coyier
Keymaster
Careful here:
$('li')[3].addClass('second-last');
When you pull an item out of the array like that it becomes a DOM node and jQuery specific functions like addClass will not work on it anymore. You’d have to do:
$('li').eq(3).addClass('second-last');
to have that work. And remember that’s 0-indexed just like arrays =)