chris 2008-7-25 17:27
jquery选择器介绍
1、选择器(selector)
基本选择
1)、id - $("#id") - 定义了ID的标签
2)、class - $(".class") - 定义了class的标签
3)、element - $("element") - 标准html元素
4)、* - $("*") - 所有元素
5)、selector1, selector2 - 选择指定的元素
等级选择
5)、ancestor descendant 祖先与后台关系
6)、parent > child 父子关系
7)、prev+next 前后关系,只选择离prev标签最近的一个next标签
8)、prev ~ siblings 兄弟姐妹关系
基本过滤器
9)、:first 匹配第一个
10)、:last 匹配最后一个
11)、:not 匹配取非值
12)、:even 匹配偶数元素
13)、:odd 匹配奇数元素
14)、:eq(index) 通过index来选取一个元素(从0开始)
15)、:gt(index) 匹配索引大于index的所有元素
16)、:lt(index) 匹配索引小于index的所有元素
17)、:header 匹配所有header标签,h1 ~ h7
18)、:animated 匹配所有当前正在进行动画过程的元素
内容过滤器
19)、:contains(text) 匹配标签内容中包含text的元素
20)、:empty 匹配内容为空的元素
21)、:has(selector) 匹配只少包含一个selector标签的元素
22)、:parent 匹配内容不为空的元素
显示隐藏
23)、:hidden 匹配隐藏的元素
24)、:visible 匹配显示的元素
属性过滤器
25)、[attribute] 匹配所有指定了attribute属性的元素
26)、[attribute=value] 匹配所有指定了atrribute属性的值为value的元素
27)、[attribute!=value] 匹配所有指定了atrribute属性的值不为value的元素
28)、[attribute^=value] 匹配所有指定了atrribute属性的值以value开头的元素
29)、[attribute$=value] 匹配所有指定了atrribute属性的值以value结尾的元素
30)、[attribute*=value] 匹配所有指定了atrribute属性的值中包括value字符串的元素
31)、[attributeFilter1][attributeFilter2][attributeFilterN] 过滤器组合使用
子元素过滤器
32)、:nth-child(index/even/odd/equation) 匹配第几个子元素 --------------------
33)、:first-child 匹配第一个子元素
34)、:last-child 匹配最后一个子元素
35)、:only-child 如果一个元素的父元素只有它这一个子元素,则匹配这一个子元素
表单
36)、:input 匹配所有input, textarea, select 和 button
38)、:text 匹配所有type=text的input
39)、:password 匹配所有type=password的input
40)、:radio 匹配所有type=radio的input
41)、:checkbox 匹配所有type=checkbox的input
42)、:submit 匹配所有type=submit的input
43)、:image 匹配所有type=image的input
44)、:reset 匹配所有type=reset的input
45)、:button 匹配所有type=button的input
46)、:file 匹配所有type=file的input
47)、:hidden 匹配所有type=hidden的input
表单过滤器
48)、:enabled 匹配所有可用的元素
49)、:disabled 匹配所有不可用的元素
50)、:checked 匹配所有被选中的元素(checkbox、radio)
51)、:selected 匹配所有被选中的元素(select)