Blogger Information
Blog 18
fans 0
comment 0
visits 9649
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
第15章 4_4自定义属性与样式操作-作业
唐朝的博客
Original
567 people have browsed it

层级选择器

1、后代选择器(空格):$("li a"),选取li元素下的所有a元素。

2、子元素选择器(>):$("ul>li"),选取ul下的所有直接子元素。

3、相邻兄弟元素选择器(+):$("li:nth-child(5)+li"),选取第6个li元素。

4、全部兄弟选择器(~):$("li:nth-child(5)~li"),选取第5个li以后的所有li元素。

5、$('li:first'),选取第一个li元素。

6、$("li:last"),选取最后一个li元素。

7、$("li:eq(5)"),选取第6个li元素,jQuery使用eq(i),序号从0开始。

8、$("li:gt(3)"),选取第4个li元素之后的所有li元素。

9、$("li:lt(3)"),选取第4个li元素之前的所有li元素。

10、$("li:even"),选取序号为偶数的li元素(实际效果是奇数)。

11、$("li:odd"),选取序号为奇数的li元素(实际效果为偶数)。


常用的过滤方法

1、get()将jQuery对象转为DOM对象。例如: $("li").get(1)

2、eq()选取指定序号的元素。例如: $("li").eq(4)

3、first()选取第一个元素。例如: $("li").first()

4、last()选取最后一个元素。例如: $("li").last()

5、toArray()返回DOM数组(不是jQuery对象)。例如: val li=$("li").toArray()

6、find()返回所有后代元素。例如: $("ul").find(("li")

7、children()返回所有直接子元素。例如: $("ul"),children()

8、each()对每个元素执行回调函数。例如: $("li").each(function())


Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!