开发者

jquery addClass to all the li:first.selection

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');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜