http://docs.jquery.com/Selectors
selectors其实也是jquery的核心内容, 没有跟core放在一起有些奇怪, 因为core的章节中已经提到了slector用法,那种类似xpath的取对象方式算得上是jquery最吸引人的特点了。
selectors基本方式:
#id Returns: Array<Element>
id属性唯一确认一个对象
element Returns: Array<Element(s)>
用name(name组成xpath)获取对象或对象数组
.class Returns: Array<Element(s)>
用class属性获取对象或对象数组
* Returns: Array<Element(s)>
*用来获取所有对象
selector1, selector2, selectorN Returns: Array<Element(s)>
用一组selectors(包含以上三种)来获取满足匹配要求的对象合集。
继承关系的选择:
ancestor descendant Returns: Array<Element(s)>
$("form input")类似这样, 用ancestor在前,descendant在后的形式来选择对象。这个形式实在非常常见。
parent > child Returns: Array<Element(s)>
$("div > input")类似这样, 来选择对象。 感觉跟$("div input")是等价的。
prev + next Returns: Array<Element(s)>
$("label + input")类似这样, 选择紧接着label的下一个兄弟对象。
prev ~ siblings Returns: Array<Element(s)>
$("label ~ input")类似这样, 选择lable的之后的全部兄弟对象。
Child Filters:
:nth-child(index/even/odd/equation) Returns: Array<Element(s)>
所选对象中,作为第n个child的对象
:first-child Returns: Array<Element(s)>
所选对象中,作为第一个child的对象
:last-child Returns: Array<Element(s)>
所选对象中,作为最后一个child的对象
:only-child Returns: Array<Element(s)>
所选对象中,作为叶子节点child的对象
基本Filters:
filters一般都是结合selectors,进一步筛选对象
:first Returns: Array<Element>
所选对象的第一个
:last Returns: Array<Element>
所选对象的最后一个
:not(selector) Returns: Array<Element(s)>
所选对象中不满足指定selector规则的对象
:even Returns: Array<Element(s)>
所选对象中的奇数编号的对象
:odd Returns: Array<Element(s)>
所选对象中的偶数编号的对象
:eq(index) Returns: Array<Element>
所选对象中的指定编号的对象
:gt(index) Returns: Array<Element(s)>
所选对象中大于指定编号的对象
:lt(index) Returns: Array<Element(s)>
所选对象中小于指定编号的对象
Content Filters:
:contains(text) Returns: Array<Element(s)>
所选对象中包含指定文本的对象
:empty Returns: Array<Element(s)>
所选对象中的没有子对象的对象(叶子对象)
:has(selector) Returns: Array<Element(s)>
所选对象中包含指定selector的对象
:parent Returns: Array<Element(s)>
所选对象中有子对象的对象(非叶子对象)
Visibility Filters:
:hidden Returns: Array<Element(s)>
所选对象中隐藏的对象
:visible Returns: Array<Element(s)>
所选对象中可见的对象
属性filter
[attribute] Returns: Array<Element(s)>
所选对象中有该属性的对象
[attribute=value] Returns: Array<Element(s)>
所选对象中,指定属性值的对象
[attribute!=value] Returns: Array<Element(s)>
所选对象中, 没有指定属性值的对象
[attribute^=value] Returns: Array<Element(s)>
所选对象中, 属性值以指定值开头的对象
[attribute$=value] Returns: Array<Element(s)>
所选对象中,属性值以指定值结束的对象
[attribute*=value] Returns: Array<Element(s)>
所选对象中,属性值以包含指定值的对象
[selector1][selector2][selectorN] Returns: Array<Element(s)>
所选对象中, 满足一组selector组合规则的对象
Forms的filter:
其实感觉这些都不算是限制于form的,不知道为何跟form扯上了关系
:input Returns: Array<Element(s)>
所有input对象
:text Returns: Array<Element(s)>
所有text对象
:password Returns: Array<Element(s)>
所有password对象
:radio Returns: Array<Element(s)>
所有radio对象
:checkbox Returns: Array<Element(s)>
所有checkbox对象
:submit Returns: Array<Element(s)>
所有submit对象
:image Returns: Array<Element(s)>
所有image对象
:reset Returns: Array<Element(s)>
所有reset对象
:button Returns: Array<Element(s)>
所有button对象
:file Returns: Array<Element(s)>
所有file对象
:hidden Returns: Array<Element(s)>
所有看不到,或者hidden的对象
:enabled Returns: Array<Element(s)>
所有enabled状态的对象
:disabled Returns: Array<Element(s)>
所有disabled状态的对象
:checked Returns: Array<Element(s)>
checked的对象
:selected Returns: Array<Element(s)>
selected的对象
分享到:
相关推荐
jQuery Selectors Refcard
We start off with a quick glance through the basics of JQuery, followed by the explanation of JQuery selectors, filters, and DOM element manipulation. After this, you will learn how events and ...
本系列文章分为:基本篇、层次篇、简单篇、内容篇、可见性篇、属性篇、子元素篇、表单篇、表单对象属性篇共9篇文章。 本篇讲解::contains(text),:empty,...jQuery-Selectors-4 .div { width:95%; margin-left:15px;
本系列文章主要讲述jQuery框架的选择器(Selectors)使用方法,我将以实例方式进行讲述,以简单,全面为基础,不会涉及很深,我的学习方法:先入门,后进阶!
本系列文章分为:基本篇、层次篇、简单篇、内容篇、可见性篇、属性篇、子元素篇、表单篇、表单对象属性篇共9篇文章。...jQuery-Selectors-9 .div { width:95%; margin-left:15px; margin-top:15px; margin-right
本系列文章主要讲述jQuery框架的选择器(Selectors)使用方法,我将以实例方式进行讲述,以简单,全面为基础,不会涉及很深,我的学习方法:先入门,后进阶!
我的学习方法:先入门,后进阶!本系列文章分为:基本篇、...jQuery-Selectors .div { width:95%; margin-left:15px; margin-top:15px; margin-right:15px; padding-left:5px; padding-top:5px; padding-botto
本系列文章主要讲述jQuery框架的选择器(Selectors)使用方法,我将以实例方式进行讲述,以简单,全面为基础,不会涉及很深,我的学习方法:先入门,后进阶!
本系列文章主要讲述jQuery框架的选择器(Selectors)使用方法,我将以实例方式进行讲述,以简单,全面为基础,不会涉及很深,我的学习方法:先入门,后进阶!
jQuery-Selectors-源码.rar
Eclipse 常用快捷键 元素事件列表说明 JQuery Effects , JQuery Traversing , JQuery Selectors , JQuery CSS 方法说明
jqueryselectors. 基础入门
3.Quick summary of jQuery selectors 4.Data centric Ajax: the $.ajax function 5.Content-centric Ajax: the load function 6.Handling JSON data 7.Comparing Ajax support to other libraries
You can now use them directly in jQuery selectors: <br>$("div.台北") $("div#台北") $("foo_bar台北") $("div[@id=台北]")Escape Selectors: A frequently requested feature you can now select ...