jQuery——过滤器
一,过滤器选择器::
:first 例如: $(‘li:first’) ----first()
:last 例如: $(‘li:last’) ----last()
:not(.red) 例如: $(‘li:not(.red)’) ----not()
:even 例如: $(‘li:even’)
:odd 例如: $(‘li:odd’)
:eq(索引值) 例如: $(‘li:eq(0)’) ----eq()
:gt(索引值) 例如: $(‘li:gt(1)’)
:lt(索引值) 例如: $(‘li:lt(1)’)
:header 例如: $(’:header’) 选择h1-h6
:animated 例如:
(
′
:
a
n
i
m
a
t
e
d
′
)
:
f
o
c
u
s
例
如
:
(':animated') :focus 例如:
(′:animated′):focus例如:(’:focus’) 初始状态需要激活
二,内容过滤器:
:contains(text) 例如: $(‘li:contains(“text”))
:has(.red) 例如: $(‘ul:has(.red)’)
选择子元素含有类的元素
:empty 例如: $(’:empty’)
:parent 例如: $(‘parent’) 含有子元素或文本
parent() ----- 获取【父元素节点】
三,可见性过滤器
:hidden 例如: $(’:hidden’)
:visible 例如: $(’:visible’)
属性:Visibility:hidden; 隐藏元素,占用文档流 也可以使用透明度为:0实现效果
Display:none; 隐藏元素,不占用文档流
四,子元素过滤器
:first-child 例如:$('li:first-child')
:last-child 例如:$('li:last-child')
:only-child 例如:$('li:only-child')
:nth-child() 例如:$('li:nth-child(1)')