一、分类
- 类选择器
- 基本选择器
- 层次选择器
- 属性选择器
- 过滤选择器
- 基本过滤选择器
- 可见性过滤选择器
二、基本选择器
- 标签选择器:element
- 类选择器:.class
- ID选择器:#id
- 并集选择器:selector1,selector2,…,selectorn
- 交集选择器:element.class或element#id(eg:$(“h2.title”))
- 全局选择器:*
三、层次选择器
- 后代选择器:ancestor descendent
- 子选择器:parent>child
- 相邻元素选择器:prev+next
- 同辈元素选择器:prev~siblings
四、属性选择器
- [attribute]:$("[href]")
- [attribute=value]:$("[name=‘user’]")
- [attribute!=value]
- [attribute^=value]:以特定值开始
- [attribute$=value]:以特定值结尾
- [attribute*=value]:包含某些值
- [selector][selector2][selectorn]:选取满足多个条件的复合属性的元素(eg:$(“li[id][title=‘新闻要点’]”))
五、基本过滤选择器
- :first:第一个元素
- :last:最后一个元素
- :even:选取索引是偶数的所有元素
- :odd:选取索引是奇数的所有元素
- :eq(index):索引等于index
- :gt(index):索引大于index
- :lt(index):索引小于index
- :not(selector):除给定选择器
- :header:所有标题元素,如h1~h6
- :focus:获取焦点
六、 可见性过滤选择器
- :visible:所有可见元素
- :hidden:所有隐藏元素