Selector | Selector
Example |
Select |
* |
$("*") |
All elements |
#ID |
$ ("#lastname") |
id= elements of "LastName" |
. class |
$ (". Intro") |
class= all elements of "intro" |
. class,. class |
$ (". Intro,.demo") |
All elements of Class "Intro" or "Demo" |
Element |
$ ("P") |
All <p> elements |
el1,el2,el3 |
$ ("h1,div,p") |
All |
|
|
|
: First |
$ ("P:first") |
First <p> Element |
: Last |
$ ("P:last") |
Last <p> Element |
: Even |
$ ("Tr:even") |
All even <tr> elements |
: Odd |
$ ("tr:odd") |
All odd <tr> elements |
|
|
|
: First-child |
$ ("P:first-child") |
All <p> elements that belong to the first child element of its parent element |
: First-of-type |
$ ("P:first-of-type") |
All <p> elements of the first <p> element that belong to its parent element |
: Last-child |
$ ("P:last-child") |
All <p> elements that belong to the last child element of its parent element |
: Last-of-type |
$ ("P:last-of-type") |
All <p> elements of the last <p> element that belong to its parent element |
: Nth-child (n) |
$ ("P:nth-child (2)") |
All <p> elements that belong to the second child element of its parent element |
: Nth-last-child (n) |
$ ("P:nth-last-child (2)") |
All <p> elements that belong to the second child element of its parent element, counting from the last child element |
: Nth-of-type (n) |
$ ("P:nth-of-type (2)") |
All <p> elements of the second <p> element that belong to its parent element |
: Nth-last-of-type (n) |
$ ("P:nth-last-of-type (2)") |
All <p> elements of the second <p> element that belong to its parent element, starting with the last child element count |
: Only-child |
$ ("P:only-child") |
All <p> elements that belong to the unique child element of its parent element |
: Only-of-type |
$ ("P:only-of-type") |
All <p> elements of a unique child element of a particular type that belong to its parent element |
|
|
|
Parent > Child |
$ ("div > P") |
<div> all <p> elements of the immediate child element of the element |
Parent descendant |
$ ("div p") |
<div> all <p> elements of descendants of an element |
Element + Next |
$ ("div + P") |
Next <p> element adjacent to each <div> element |
Element ~ Siblings |
$ ("div ~ P") |
<div> all <p> elements of an element's peers |
|
|
|
: eq (index) |
$ ("UL Li:eq (3)") |
The fourth element in the list (the index value starts at 0) |
: GT (no) |
$ ("UL li:gt (3)") |
Enumerate elements with index greater than 3 |
: LT (no) |
$ ("UL Li:lt (3)") |
Enumerate elements with index less than 3 |
: Not (selector) |
$ ("Input:not (: Empty)") |
All input elements that are not empty |
|
|
|
: Header |
$ (": Header") |
All title elements |
: Animated |
$ (": animated") |
All animated elements |
: Focus |
$ (": Focus") |
The element that currently has focus |
: Contains (text) |
$ (": Contains (' Hello ')") |
All elements that contain the text "Hello" |
: Has (selector) |
$ ("Div:has (P)") |
All <div> elements that contain <p> elements |
: Empty |
$ (": Empty") |
All empty elements |
:p arent |
$ (":p arent") |
Selects all parent elements that contain child elements or text.
|
: Hidden |
$ ("P:hidden") |
All hidden <p> elements |
: Visible |
$ ("table:visible") |
All the visible tables |
: Root |
$ (": Root") |
The root element of the document |
: lang (language) |
$ ("P:lang (DE)") |
All <p> elements with the value of the lang attribute starting with "de" |
|
|
|
[attribute] |
$ ("[href]") |
All elements with an HREF attribute |
[attribute=value] |
$ ("[href= ' default.htm ']") |
All elements with an HREF attribute and a value equal to "default.htm" |
[attribute! =value] |
$ ("[href!= ' default.htm ']") |
All elements with href attribute and value not equal to "default.htm" |
[attribute$=value] |
$ ("[href$= '. jpg ']") |
All elements with the href attribute and the value ending with ". jpg" |
[attribute|=value] |
$ ("[title|= ' Tomorrow ']") |
All strings with the title attribute with a value equal to ' tomorrow ' or a ' tomorrow ' followed by a connector |
[attribute^=value] |
$ ("[title^= ' Tom ']") |
All elements with the title attribute and the value beginning with "Tom" |
[attribute~=value] |
$ ("[title~= ' Hello ']") |
All elements with the title attribute and the value contains the word "Hello" |
[attribute*=value] |
$ ("[title*= ' Hello ']") |
All elements with the title attribute and the value containing the string "Hello" |
|
|
|
: input |
$ (": input") |
All input elements |
: Text |
$ (": Text") |
All input elements with type= "text" |
:p Assword |
$ (":p Assword") |
All input elements with type= "password" |
|
: checkbox |
$ (": checkbox") |
All input elements with type= "checkbox" |
: Submit |
$ (": Submit") |
All input elements with type= "Submit" |
: RESET |
$ (": Reset") |
All input elements with type= "reset" |
: button |
$ (": Button") |
All input elements with type= "button" |
: Image |
$ (": Image") |
All input elements with type= "image" |
: File |
$ (": File") |
All input elements with type= "file" |
: Enabled |
$ (": Enabled") |
All input elements that are enabled |
:d isabled |
$ (":d isabled") |
All disabled input elements |
: Selected |
$ (": Selected") |
All the selected input elements |
|
|
: Checked |
$ (": Checked") |
All the selected input elements |