jQuery1.2选择器
以下的文档根据官网1.2选择器汉化,并做相应的调整及加入了部份示例。
由于实际使用中选择器在IE和非IE下会有不同的效果,请参照红色的字样。如有错误请及时联系我。
绯雨汉化:http://feiyu.asgard.cn
	
基本选择器
| #myid | 返回: 对象> | 
| 匹配一个id为myid的元素。 | |
| element | 返回: 对象> 数组 | 
| 匹配所有的element元素 | |
| .myclass | 返回: 对象> 数组 | 
| 匹配所有class为myclass的元素 | |
| * | 返回: 对象> 数组 | 
| 匹配所有元素。该选择器会选择文档中所有的元素,包括html,head,body | |
| selector1,selector2,selectorN | 返回: 对象> 数组 | 
| 匹配所有满足selector1或selector2或selectorN的元素 | |
层次选择
| elementParent elementChild | 返回: 对象> 数组 | 
| 匹配elementParent下的所有子元素elementChild。例如:$("div p") 选择所有div下的p元素 | |
| elementParent > elementChild | 返回: 对象> 数组 | 
| 匹配elementParent下的子元素elementChild。例如:$("div>p") 选择所有上级元素为div的p元素 | |
| prev+next | 返回: 对象> 数组 | 
| 匹配prev同级之后紧邻的元素next。例如:$("h1+div") 选择所有div同级之前为h1的元素() | |
| prev ~ siblings | 返回: 对象> 数组 | 
| 匹配prev同级之后的元素siblings。例如:$("h1~div") 可以匹配() | |
基本滤镜
| :first | 返回: 对象> | 
| 匹配第一个元素 | |
| :last | 返回: 对象> | 
| 匹配最后一个元素 | |
| :not(selector) | 返回: 对象> 数组 | 
| 匹配不满足selector的元素 | |
| :has(selector) | 返回: 对象> 数组 | 
| 匹配包含满足selector的元素。此选择器为1.2新增 | |
| :even | 返回: 对象> 数组 | 
| 从匹配的元素集中取序数为偶数的元素。 | |
| :odd | 返回: 对象> 数组 | 
| 从匹配的元素集中取序数为奇数的元素。 | |
| :eq(index) | 返回: 对象> 数组 | 
| 从匹配的元素集中取第index个元素 | |
| :gt(index) | 返回: 对象> 数组 | 
| 从匹配的元素中取序数大于index的元素 | |
| :lt(index) | 返回: 对象> 数组 | 
| 从匹配的元素中取序数小于index的元素 | |
| :header | 返回: 对象> 数组 | 
| 匹配所有的标题元素,例如h1,h2,h3……hN。此选择器为1.2新增 | |
| :animated | 返回: 对象> 数组 | 
| 匹配正在执行动画的元素。此选择器为1.2新增 | |
| :empty | 返回: 对象> 数组 | 
| 匹配所有没有子元素(包括文本内容)的元素 | |
| :parent | 返回: 对象> 数组 | 
| 匹配包含子元素(包含文本内容)的所有元素 | |
| :contains(text) | 返回: 对象> 数组 | 
| 匹配所有含有text的元素 | |
| :hidden | 返回: 对象> 数组 | 
| 匹配所有隐藏的元素,包含属性type值为hidden的元素 | |
| :visible | 返回: 对象> 数组 | 
| 匹配所有非隐藏的元素 | |
子元素滤镜
| E:nth-child(index/even/odd/equation) | 返回: 对象> 数组 | 
| 匹配所有E在其父元素下满足(index/even/odd/equation)条件的集合。注:下标从1开始 | |
| E:first-child | 返回: 对象> 数组 | 
| 匹配所有E在其父元素下是第一个子元素的集合。例如:HTML("),使用$("p:first-child"),选取: | |
| E:last-child | 返回: 对象> 数组 | 
| 匹配所有E在其父元素下是最后一个子元素的集合。例如:同上的HTML,使用$("p:last-child"),选取: | |
| E:only-child | 返回: 对象> 数组 | 
| 匹配所有E是其父元素的唯一子元素的集合。例如:同上的HTML,使用$("p:only-child"),选取: | |
表单滤镜
| :input | 返回: 对象> 数组 | 
| 匹配所有的input、textarea、select、button | |
| :text | 返回: 对象> 数组 | 
| 匹配文本域。注:在IE浏览器下,选择的对象是所有type属性为text的元素,在非IE浏览器下,选择的对象是input元素type属性为text的元素 | |
| :password | 返回: 对象> 数组 | 
| 匹配密码域。注:在IE浏览器下,选择的对象是所有type属性为password的元素,在非IE浏览器下,选择的对象是input元素type属性为password的元素 | |
| :radio | 返回: 对象> 数组 | 
| 匹配单选按钮。注:在IE浏览器下,选择的对象是所有type属性为radio的元素,在非IE浏览器下,选择的对象是input元素type属性为radio的元素 | |
| :checkbox | 返回: 对象> 数组 | 
| 匹配复选框。注:在IE浏览器下,选择的对象是所有type属性为checkbox的元素,在非IE浏览器下,选择的对象是input元素type属性为checkbox的元素 | |
| :submit | 返回: 对象> 数组 | 
| 匹配提交按钮。注:在IE浏览器下,选择的对象是所有type属性为submit的元素,在非IE浏览器下,选择的对象是input元素type属性为submit的元素和button元素type属性为空或为submit的元素 | |
| :image | 返回: 对象> 数组 | 
| 匹配图像域。注:在IE浏览器下,选择的对象是所有type属性为image的元素,在非IE浏览器下,选择的对象是input元素type属性为image的元素 | |
| :reset | 返回: 对象> 数组 | 
| 匹配重置按钮。注:在IE浏览器下,选择的对象是所有type属性为reset的元素,在非IE浏览器下,选择的对象是input或button元素type属性为reset的元素 | |
| :button | 返回: 对象> 数组 | 
| 匹配按钮。注:在IE浏览器下,选择的对象是所有type属性为button的元素和元素名为button的元素,在非IE浏览器下,选择的对象是input元素type属性为button的元素和元素名为button的元素 | |
| :file | 返回: 对象> 数组 | 
| 匹配文件域。注:在IE浏览器下,选择的对象是所有type属性为file的元素,在非IE浏览器下,选择的对象是input元素type属性为file的元素 | |
| :enabled | 返回: 对象> 数组 | 
| 匹配所有可用的元素。注:即:not(:disabled),参考:disabled的注释 | |
| :disabled | 返回: 对象> 数组 | 
| 匹配所有禁用的元素。注:在非IE浏览器下,选择的对象是禁用的表单元素 | |
| :checked | 返回: 对象> 数组 | 
| 匹配所有被选中的表单。注:在IE浏览器下,选择的对象是含有checked属性的所有元素 | |
| :selected | 返回: 对象> 数组 | 
| 匹配所有选择的表单。注:在IE浏览器下,选择的对象是含有selected属性的所有元素 | |
属性滤镜
| [attribute] | 返回: 对象> 数组 | 
| 匹配拥有attribute属性的元素 | |
| [attribute=value] | 返回: 对象> 数组 | 
| 匹配属性attribute为value的元素 | |
| [attribute!=value] | 返回: 对象> 数组 | 
| 匹配属性attribute不为value的元素 | |
| [attribute^=value] | 返回: 对象> 数组 | 
| 匹配属性attribute的值以value开始的元素 | |
| [attribute$=value] | 返回: 对象> 数组 | 
| 匹配属性attribute的值以value结尾的元素 | |
| [attribute*=value] | 返回: 对象> 数组 | 
| 匹配属性attribute的值包含value的元素 | |
| [selector1][selector2][selectorN] | 返回: 对象> 数组 | 
| 匹配满足属性选择器selector1、selector2、selectorN的元素 | |
热榜
这个热榜展示了最常用选择器的排名,数据是根据使用jQuery的著名网站分析得来的。热榜中的选择器已被归类(如,'div span'和'ul li'都是'tag tag'形式)。红色部分表示与W3C规范不兼容。% Used一栏表示选择器使用百分比(# of Uses一栏表示选择器使用次数)。只用过一次的选择器没在热榜中罗列。
| % Used | # of Uses | |
| #id | 51.290% | 1431 | 
| .class | 13.082% | 365 | 
| tag | 6.416% | 179 | 
| tag.class | 3.978% | 111 | 
| #id tag | 2.151% | 60 | 
| tag#id | 1.935% | 54 | 
| #id:visible | 1.577% | 44 | 
| #id .class | 1.434% | 40 | 
| .class .class | 1.183% | 33 | 
| * | 0.968% | 27 | 
| #id tag.class | 0.932% | 26 | 
| #id:hidden | 0.789% | 22 | 
| tag[name=value] | 0.645% | 18 | 
| .class tag | 0.573% | 16 | 
| [name=value] | 0.538% | 15 | 
| tag tag | 0.502% | 14 | 
| #id #id | 0.430% | 12 | 
| #id tag tag | 0.358% | 10 | 
| tag[name$=value] | 0.323% | 9 | 
| #id :checkbox | 0.323% | 9 | 
| #id #id :selected | 0.287% | 8 | 
| .class tag.class | 0.287% | 8 | 
| tag#id > tag | 0.287% | 8 | 
| tag, tag | 0.251% | 7 | 
| tag.class tag | 0.251% | 7 | 
| tag .class | 0.215% | 6 | 
| :radio | 0.215% | 6 | 
| #id, #id, #id | 0.215% | 6 | 
| #id .class tag | 0.215% | 6 | 
| :text | 0.215% | 6 | 
| tag, tag, tag | 0.215% | 6 | 
| .class .class .class | 0.215% | 6 | 
| #id tag[name=value] | 0.179% | 5 | 
| :checkbox | 0.179% | 5 | 
| tag[name*=value] | 0.179% | 5 | 
| #id, #id | 0.179% | 5 | 
| tag.class tag.class tag | 0.143% | 4 | 
| tag.class .class | 0.143% | 4 | 
| tag:selected | 0.143% | 4 | 
| .class .class .class tag | 0.143% | 4 | 
| .class.class | 0.143% | 4 | 
| tag:file | 0.143% | 4 | 
| tag, tag[name=value] | 0.143% | 4 | 
| #id, tag[name$=value] | 0.143% | 4 | 
| tag[name!=value] | 0.143% | 4 | 
| .class .class tag + .class | 0.108% | 3 | 
| .class .class tag:gt(2) | 0.108% | 3 | 
| tag:submit, tag:image, tag:submit | 0.108% | 3 | 
| tag.class tag.class tag.class tag.class tag.class tag.class | 0.108% | 3 | 
| #id tag tag.class tag.class tag | 0.108% | 3 | 
| :input | 0.108% | 3 | 
| tag.class tag.class | 0.108% | 3 | 
| .class .class tag:has(tag[name^=value]) | 0.108% | 3 | 
| #id tag.class tag | 0.108% | 3 | 
| tag:eq(0) | 0.108% | 3 | 
| #id :input | 0.108% | 3 | 
| tag#id tag#id tag | 0.108% | 3 | 
| .class, .class | 0.108% | 3 | 
| tag:eq(1) | 0.108% | 3 | 
| tag#id tag | 0.108% | 3 | 
| .class tag#id | 0.072% | 2 | 
| #id tag:first | 0.072% | 2 | 
| #id tag tag[name!=value] | 0.072% | 2 | 
| .class #id tag tag | 0.072% | 2 | 
| tag#id tag.class | 0.072% | 2 | 
| tag:filled | 0.072% | 2 | 
| tag:first | 0.072% | 2 | 
| .class tag tag.class | 0.072% | 2 | 
| #id tag.class tag tag.class | 0.072% | 2 | 
| tag.class tag.class tag.class | 0.072% | 2 | 
| #id #id #id tag.class | 0.072% | 2 | 
| tag[name$=value], #id | 0.072% | 2 | 
| tag tag tag | 0.072% | 2 | 
| :submit, tag:image | 0.072% | 2 | 
| .class .class tag | 0.072% | 2 | 
| [name=value]:first | 0.072% | 2 | 
| .class .class, #id | 0.072% | 2 | 
| #id .class tag.class | 0.072% | 2 | 
| .class #id .class | 0.072% | 2 | 
| #id #id tag tag | 0.072% | 2 | 
| tag[name] | 0.072% | 2 | 
| tag, tag, tag, tag | 0.072% | 2 | 
| tag#id tag#id tag.class | 0.072% | 2 | 
| tag:unchecked | 0.072% | 2 | 
| #id .class.class | 0.072% | 2 | 
| #id tag.class tag > tag | 0.072% | 2 | 
| .class tag tag tag | 0.072% | 2 | 
| tag.class:first | 0.072% | 2 | 
| .class tag.class tag | 0.072% | 2 | 
| tag#id tag.class:first | 0.072% | 2 | 
| #id tag.class tag.class tag | 0.072% | 2 | 
| .class tag tag | 0.072% | 2 | 
| #id .class tag tag | 0.072% | 2 | 
| #id tag tag#id | 0.072% | 2 | 
| tag.class > tag | 0.072% | 2 | 
| #id .class * | 0.072% | 2 | 
| :input:visible | 0.072% | 2 | 
| #id .class .class | 0.072% | 2 | 
| #id > tag > tag > tag > tag > tag | 0.072% | 2 | 
| #id tag.class tag tag:gt(0) | 0.072% | 2 | 
| .class, .class, .class | 0.072% | 2 | 
| #id #id * | 0.072% | 2 | 
| #id > *:not(#id) | 0.072% | 2 | 
| #id tag[name^=value] | 0.072% | 2 | 
| .class tag.class | 0.072% | 2 | 
| tag:blank | 0.072% | 2 | 



 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                 
            
                