jQuery选择器
基本筛选选择器
$(":first")
匹配第一个元素
$(":last")
匹配最后一个元素$(":not(select)")
去掉不匹配的选择器元素$(":eq(index)")
在匹配的集合中选择索引值为index的元素$(":gt(index)")
选择匹配集合中所有大于给定index(索引值)的元素$(":even")
选择索引值为偶数的元素,从0开始计数$(":odd")
选择索引值为奇数的元素,从0开始计数$(":lt(index)")
选择匹配集合中所有索引值小于给定index参数的元素$(":header")
选择所有标题元素,像h1,h2,h3等$("lang(language)")
选择指定语言的所有元素$(":root")
选择该文档的根元素$(":animated")
选择所有正在执行动画效果的元素 div:first
:even
:odd
:even
:odd
:even
div:last
:odd
demo
链接描述内容筛选选择器
$(":contain(text)")
选择所有包含指定文本的元素
$(":parent")
选择所有含有子元素或者文本的元素$(":empty")
选择所有没有子元素的元素(包括文本节点)$(":has(selector)")
选择元素中至少包含指定选择器的元素图片描述 contains
:contains
:has
:contains
:parent/:empty
demo
子元素筛选选择器
$(:first-chid) //选择所有父元素级下的第一个子元素$(:last-child) //选择所有父元素下的最后一个元素$(:only-child) //如果某元素是其父元素的唯一子元素,那么它就会被选中$(:nth-child) //选择他们所有父元素的第n个元素$(:nth-last-child) //选择他们所有父元素的第n个元素,计数从最后一个元素到第一个
子元素筛选选择器
:first-child、:last-child、:only-child
:nth-child、:nth-last-child
表单元素选择器
$(:input)
选择所有input,textarea,select和button元素
$(:text)
匹配所有文本框$(:password)
匹配所有密码框$(:radio)
匹配所有单选按钮$(:checkbox)
匹配所有复选框$(:submit)
匹配所有提交按钮$(:image)
匹配所有图像域$(:reset)
匹配所有重置按钮$(:button)
匹配所有按钮$(:file)
匹配所有按钮 <h2>子元素筛选选择器</h2> input、text、password、radio、checkbox
submit、image、reset、button、file
[1]: http://codepen.io/i-summer/pen/EWjZLv [2]: http://codepen.io/i-summer/details/RpPpKX/ [3]: /img/bVJImf