jquery的选择器

基本选择器

#id  $("#id")

.class   $("#.class)  

element  $("p")  选择p标签

*           $("*")   选择所有元素

select1,select2,select3    $("div,span,p")  选择所有div,span,p元素

select#id.class     $("p#head")  选择含有id为head的p元素

 

层次选择器

 

$("div   span")   选择div元素下的所有span元素

$("div>span")   选择div元素下的元素名是span的子元素

$(".one+div")   选择class是one的下一个div兄弟元素(紧邻兄弟元素)

$(".one~div")   选择class是one后面的所有div兄弟元素(所有兄弟元素)

 

表单选择器

:input     选择所有input,textarea,select,button

:text      选择所有单行文本框

:password  选择所有密码框

:radio  选择所有单选框

:checkbox   选择所有多选框

:submit   选择所有提交按钮

:image    选择所有图片按钮

:reset      选择所有重置按钮

:button     选择所有按钮

:file           选择所有上传域

:hidden     选择所有不可见元素

 

过滤选择器

 

基本过滤

:first        选取第一个

:last         选取最后一个

:even       选择偶数

:odd        选择奇数

:eq(index)   等于

:gt(index)    大于

:lt(index)    小于

:not(select)    去除选择元素

:header    h1——h6

:animated  选择所有正在执行的动画元素

 

内容过滤

:contains()  $("div:contains('我')")    选取包含文本“我”的div元素

:empty       $("div:empty")         选择div空元素

:has(select)  $("div:has('p')")   选择包含p元素的div元素

:parent     $("div:parent")   选择有子元素的div

 

可见性过滤

:hidden

:visible

属性过滤

[attribute]

[attribute=value]

[attribute!=value]

[attribute^=value]

[attribute$=value]

[attribute*=value]

[select1][select2][selectN]

子元素过滤

:nth-child()

:first-child

:last-child

only-child

表单对象属性过滤

:enabled

:disabled

:checked

:selected

posted @ 2012-11-29 13:48  fsl  阅读(343)  评论(0编辑  收藏  举报