jQuery学习笔记,二

1. 基本选择器

  #id ("#one")

.class $(".two")

element (根据给定的元素名匹配元素) $("div")

* (匹配所有元素) $("*")

  slector1,selector2,...,selector2 $("div,span,p.two")

2. 层次选择器

  $("ancestor discendant") 选择ancestor 中的所有 discendant 后代元素

  $("parent chilid") 选择 parent 元素下的 child (子)元素 注:只限子元素

$("prev + next") 匹配所有紧接在 prev 元素后的 next 元素

$("prev ~ siblings") 匹配 prev 元素之后的所有 siblings 元素

3. 基本过滤选择器

  :first

:last

  :not(selector) 注: 注意不带引号 1.3 后支持 :not(div a ) not(div, a)

:even 偶数

:odd 索引为奇数

:eq(index) 匹配一个给定索引值的元素

:gt(index) 匹配一个大于索引值的元素

:lt(index) 小于

:header 匹配标题元素

:animated 匹配所有正在执行动画效果的元素

4. 内容过滤选择器

  :contains(text) 选择含有文本内容为 text 的元素

:empty 选择不包含子元素或者文本内容为空的元素

:has(selector) 选择含有选择器所匹配的元素的元素 注: 括号内不含引号

:parent 选择含有子元素或者文本的元素

5. 可见性过滤选择器

  :hidden

  :visible

6. 属性选择器

7. 子元素过滤器