jquery中的选择器表达式 【转载】
2009-06-05 12:25
239 查看
官方的文档:http://docs.jquery.com/Selectors。真是神奇。它的语法是结合了CSS和XPATH的特点的
API/1.3/Selectors
(Redirected from Selectors) Basics: #id
Returns: Array<Element> Matches a single element with the given id attribute. element
Returns: Array<Element(s)> Matches all elements with the given name. .class
Returns: Array<Element(s)> Matches all elements with the given class. .class.class
Returns: Array<Element(s)> Matches all elements with the given classes. *
Returns: Array<Element(s)> Matches all elements. selector1, selector2, selectorN
Returns: Array<Element(s)> Matches the combined results of all the specified selectors.
Hierarchy: Returns: Array<Element> Matches a single element with the given id attribute. element
Returns: Array<Element(s)> Matches all elements with the given name. .class
Returns: Array<Element(s)> Matches all elements with the given class. .class.class
Returns: Array<Element(s)> Matches all elements with the given classes. *
Returns: Array<Element(s)> Matches all elements. selector1, selector2, selectorN
Returns: Array<Element(s)> Matches the combined results of all the specified selectors.
ancestor descendant
Returns: Array<Element(s)> Matches all descendant elements specified by "descendant" of elements specified by "ancestor". parent > child
Returns: Array<Element(s)> Matches all child elements specified by "child" of elements specified by "parent". prev + next
Returns: Array<Element(s)> Matches all next elements specified by "next" that are next to elements specified by "prev". prev ~ siblings
Returns: Array<Element(s)> Matches all sibling elements after the "prev" element that match the filtering "siblings" selector.
Basic Filters: Returns: Array<Element(s)> Matches all descendant elements specified by "descendant" of elements specified by "ancestor". parent > child
Returns: Array<Element(s)> Matches all child elements specified by "child" of elements specified by "parent". prev + next
Returns: Array<Element(s)> Matches all next elements specified by "next" that are next to elements specified by "prev". prev ~ siblings
Returns: Array<Element(s)> Matches all sibling elements after the "prev" element that match the filtering "siblings" selector.
:first
Returns: Array<Element> Matches the first selected element. :last
Returns: Array<Element> Matches the last selected element. :not(selector)
Returns: Array<Element(s)> Filters out all elements matching the given selector. :even
Returns: Array<Element(s)> Matches even elements, zero-indexed. :odd
Returns: Array<Element(s)> Matches odd elements, zero-indexed. :eq(index)
Returns: Array<Element> Matches a single element by its index. :gt(index)
Returns: Array<Element(s)> Matches all elements with an index above the given one. :lt(index)
Returns: Array<Element(s)> Matches all elements with an index below the given one. :header
Returns: Array<Element(s)> Matches all elements that are headers, like h1, h2, h3 and so on. :animated
Returns: Array<Element(s)> Matches all elements that are currently being animated.
Content Filters: Returns: Array<Element> Matches the first selected element. :last
Returns: Array<Element> Matches the last selected element. :not(selector)
Returns: Array<Element(s)> Filters out all elements matching the given selector. :even
Returns: Array<Element(s)> Matches even elements, zero-indexed. :odd
Returns: Array<Element(s)> Matches odd elements, zero-indexed. :eq(index)
Returns: Array<Element> Matches a single element by its index. :gt(index)
Returns: Array<Element(s)> Matches all elements with an index above the given one. :lt(index)
Returns: Array<Element(s)> Matches all elements with an index below the given one. :header
Returns: Array<Element(s)> Matches all elements that are headers, like h1, h2, h3 and so on. :animated
Returns: Array<Element(s)> Matches all elements that are currently being animated.
:contains(text)
Returns: Array<Element(s)> Matches elements which contain the given text. :empty
Returns: Array<Element(s)> Matches all elements that have no children (including text nodes). :has(selector)
Returns: Array<Element(s)> Matches elements which contain at least one element that matches the specified selector. :parent
Returns: Array<Element(s)> Matches all elements that are parents - they have child elements, including text.
Visibility Filters: Returns: Array<Element(s)> Matches elements which contain the given text. :empty
Returns: Array<Element(s)> Matches all elements that have no children (including text nodes). :has(selector)
Returns: Array<Element(s)> Matches elements which contain at least one element that matches the specified selector. :parent
Returns: Array<Element(s)> Matches all elements that are parents - they have child elements, including text.
:hidden
Returns: Array<Element(s)>
Matches all elements that are hidden. :visible
Returns: Array<Element(s)> Matches all elements that are visible.
Attribute Filters:Note: In jQuery 1.3 [@attr] style selectors were removed (they were previously deprecated in jQuery 1.2). Simply remove the '@' symbol from your selectors in order to make them work again. Returns: Array<Element(s)>
Matches all elements that are hidden. :visible
Returns: Array<Element(s)> Matches all elements that are visible.
[attribute]
Returns: Array<Element(s)> Matches elements that have the specified attribute. Note the "@" before the attribute name was deprecated as of version 1.2. [attribute=value]
Returns: Array<Element(s)> Matches elements that have the specified attribute with a certain value. [attribute!=value]
Returns: Array<Element(s)> Matches elements that either don't have the specified attribute or do have the specified attribute but not with a certain value. [attribute^=value]
Returns: Array<Element(s)> Matches elements that have the specified attribute and it starts with a certain value. [attribute$=value]
Returns: Array<Element(s)> Matches elements that have the specified attribute and it ends with a certain value. [attribute*=value]
Returns: Array<Element(s)> Matches elements that have the specified attribute and it contains a certain value. [attributeFilter1][attributeFilter2][attributeFilterN]
Returns: Array<Element(s)> Matches elements that match all of the specified attribute filters.
Child Filters: Returns: Array<Element(s)> Matches elements that have the specified attribute. Note the "@" before the attribute name was deprecated as of version 1.2. [attribute=value]
Returns: Array<Element(s)> Matches elements that have the specified attribute with a certain value. [attribute!=value]
Returns: Array<Element(s)> Matches elements that either don't have the specified attribute or do have the specified attribute but not with a certain value. [attribute^=value]
Returns: Array<Element(s)> Matches elements that have the specified attribute and it starts with a certain value. [attribute$=value]
Returns: Array<Element(s)> Matches elements that have the specified attribute and it ends with a certain value. [attribute*=value]
Returns: Array<Element(s)> Matches elements that have the specified attribute and it contains a certain value. [attributeFilter1][attributeFilter2][attributeFilterN]
Returns: Array<Element(s)> Matches elements that match all of the specified attribute filters.
:nth-child(index/even/odd/equation)
Returns: Array<Element(s)> Matches all elements that are the nth-child of their parent or that are the parent's even or odd children. :first-child
Returns: Array<Element(s)> Matches all elements that are the first child of their parent. :last-child
Returns: Array<Element(s)> Matches all elements that are the last child of their parent. :only-child
Returns: Array<Element(s)> Matches all elements that are the only child of their parent.
Forms: Returns: Array<Element(s)> Matches all elements that are the nth-child of their parent or that are the parent's even or odd children. :first-child
Returns: Array<Element(s)> Matches all elements that are the first child of their parent. :last-child
Returns: Array<Element(s)> Matches all elements that are the last child of their parent. :only-child
Returns: Array<Element(s)> Matches all elements that are the only child of their parent.
:input
Returns: Array<Element(s)> Matches all input, textarea, select and button elements. :text
Returns: Array<Element(s)> Matches all input elements of type text. :password
Returns: Array<Element(s)> Matches all input elements of type password. :radio
Returns: Array<Element(s)> Matches all input elements of type radio. :checkbox
Returns: Array<Element(s)> Matches all input elements of type checkbox. :submit
Returns: Array<Element(s)> Matches all input elements of type submit. :image
Returns: Array<Element(s)> Matches all input elements of type image. :reset
Returns: Array<Element(s)> Matches all input elements of type reset. :button
Returns: Array<Element(s)> Matches all button elements and input elements of type button. :file
Returns: Array<Element(s)> Matches all input elements of type file. :hidden
Returns: Array<Element(s)>
Returns: Array<Element(s)> Matches all input, textarea, select and button elements. :text
Returns: Array<Element(s)> Matches all input elements of type text. :password
Returns: Array<Element(s)> Matches all input elements of type password. :radio
Returns: Array<Element(s)> Matches all input elements of type radio. :checkbox
Returns: Array<Element(s)> Matches all input elements of type checkbox. :submit
Returns: Array<Element(s)> Matches all input elements of type submit. :image
Returns: Array<Element(s)> Matches all input elements of type image. :reset
Returns: Array<Element(s)> Matches all input elements of type reset. :button
Returns: Array<Element(s)> Matches all button elements and input elements of type button. :file
Returns: Array<Element(s)> Matches all input elements of type file. :hidden
Returns: Array<Element(s)>
Matches all elements that are hidden.
Form Filters: :enabled
Returns: Array<Element(s)> Matches all elements that are enabled. :disabled
Returns: Array<Element(s)> Matches all elements that are disabled. :checked
Returns: Array<Element(s)> Matches all elements that are checked. :selected
Returns: Array<Element(s)> Matches all elements that are selected. [edit] Special characters in selectors If you wish to use any of the meta-characters described above as a literal part of a name, you must escape the character with two backslashes (\\). For example:
The full list of characters that need to be escaped:
Returns: Array<Element(s)> Matches all elements that are enabled. :disabled
Returns: Array<Element(s)> Matches all elements that are disabled. :checked
Returns: Array<Element(s)> Matches all elements that are checked. :selected
Returns: Array<Element(s)> Matches all elements that are selected. [edit] Special characters in selectors If you wish to use any of the meta-characters described above as a literal part of a name, you must escape the character with two backslashes (\\). For example:
#foo\\:bar #foo\\[bar\\] #foo\\.bar
The full list of characters that need to be escaped:
#;&,.+*~':"!^$[]()=>|/
相关文章推荐
- jquery中的选择器表达式 【转载】
- JQuery选择器中使用正则表达式实例
- jquery选择器(转载)
- Jquery-各种选择器,转载自jb51
- JQuery选择器中使用正则表达式实例
- JQuery选择器中使用正则表达式实例
- 关于jQuery选择器的完成介绍(转载)
- jQuery 选择器【转载于jQuery手册(选择器部分)】
- [转载]javascript+ajax+jquery教程11--正则表达式
- JQuery选择器转载
- jQuery选择器总结(转载)
- JQUERY选择器大全(转载)
- Jquery选择器(转载)
- javascript笔记:String的replace(续),由正则表达式到jQuery选择器
- 详解jQuery选择器正则表达式
- [乐意黎转载]从零开始学习jQuery (二) 万能的选择器
- jQuery-Selectors(选择器)的使用(二、层次篇)(转载)
- jquery选择器(转载)
- jQuery选择器总结[转载]
- jquery选择器(转载)