I'm trying to select the first list item li in the ul#suckerfishnav in the main navigation here: http://fluroltd开发者_如何转开发.com/clients/harveys/. Using
$('ul#suckerfishnav').find('li').slice(0,1) {
$(this).css('background-color', 'red');
});
My aim is to add a class="first" to the first li in the list.
Try this:
$('ul#suckerfishnav li:first-child').addClass("first");
I've updated your jsFiddle to show it working
You could just use plain CSS for this too:
#suckerfishnav li:first-child {background-color:Red;);
精彩评论