Home  >  Article  >  Web Front-end  >  Jquery 过滤器(first,last,not,even,odd)的使用_jquery

Jquery 过滤器(first,last,not,even,odd)的使用_jquery

WBOY
WBOYOriginal
2016-05-16 17:02:491181browse

复制代码 代码如下:

$(function(){
$("#menu li:first").click(function(){
$(this).addClass("b");
});
$("#menu li:last").text("最后");//id为menu的li列表中最后一个li元素插入文字“最后”
$("#menu li:first").text("第一");//li列表中第一个li元素插入文字“第一”
$("#menu li:not(.on)").text("on");//li列表中样式不是class="on"的li元素插入文字“on”
$("#menu li:even").text("奇数行");
$("#menu li:odd").text("偶数行");
});
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn