jquery how to addClass to all the ul.menu
li:first.selection
?
demo code here:
http://jsfiddle.net/NkbDY/
I need menu1
menu4
menu7
, all the first 开发者_开发技巧li
in ul.menu
change font color to red.
Thanks.
$('ul.menu li:first-child').addClass('current');
http://jsfiddle.net/NkbDY/1/
$('ul.menu').each(function(i,e){
$('li:first',e).addClass('current');
});
Group my .menu
first, then find the first of each menu.
More concisely, first-child
also does this:
$('ul.menu li:first-child').addClass('current');
精彩评论