`

JQuery 选择器

阅读更多

1.基本选择器

#id id选择器,加#号
tagName 字母开头,表示tag名,比如p,div
.class .开头,表示css类选择
* 全选
selector1,selector2,selector3 ,分隔,表示多个选择器

2.层次选择器

ancestor descendant 空格分隔,表示所有后代(子元素及子元素的子元素...
parent>child >分隔,表示子元素
prev+next +分隔表示紧跟在prev之后的相邻元素
prev~siblings ~分隔,表示跟在prev之后所有的元素

3.过滤选择器

first(),或:first  
last(),或:last  
:not(selector) 取反
:even  
:odd  
:eq(index)  
:gt(index)  
:lt(index)  
:header 所有标题类型的元素,比如h1,h2
:animated 正在执行动画的元素

 

4.内容过滤器

:contains(text) 包含文本内容
:empty 不包含子元素与文本内容的
:has(selector) 拥有某选择器的
:parent 父元素

5.可见性过滤器

:hidden  
:visible  

6.属性过滤器

[attribute] 包含给定的属性
[attribute=value] 指定的属性等于指定的值
[attribute!=value] 指定的属性不等于指定的值
[attribute^=value] 指定的属性值开头等于指定的值
[attribute$=value] 指定的属性值结尾等于指定的值
[attribute*=value] 指定的属性值包含指定的值
[attr-selector][attr-selector][attr-selector] 同时满足几个属性条件

7.子元素过滤器

:nth-child(eq|even|odd|index) 获取父元素下的特定的子元素,index 从1开始
:first-child 第一个子元素
:last-child 最后一个子元素
:only-child 获取仅有的一个子元素

8.表单对象 属性过滤器

:enabled  
:disabled  
:checked  
:selected option里被选中的

 9.表单对象选择器

:input 包含text,textarea,select
:text 只包含单选输入的 text
:password  
:radio  
:checkbox  
:submit  
:image  
:reset reset 按钮
:button  
:file  

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics