JQuery Add class to certain list item

jquery, list

Solution

Use `.eq()`

$('.navigation ul li').eq(0).addClass("active");

http://api.jquery.com/eq/

Why `get()` didn't worked ? see this - jQuery : eq() vs get()

Problem

I am trying to add a script that will add a class to a list item that I choose.. I have tried this but it didnt add the class ``` $('.navigation ul li').get(0).addClass("active"); ``` What Am i doing wrong?

Original source

Related problems