Selector | Selector
Example |
Select |
* |
$("*") |
All elements |
#ID |
$ ("#lastname") |
id= elements of "LastName" |
. class |
$ (". Intro") |
All elements of class= "Intro" |
Element |
$ ("P") |
All <p> elements |
. class. class |
$ (". Intro.demo") |
All class= "Intro" and Class= "demo" Elements |
|
|
|
: 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 |
|
|
|
: eq (index) |
$ ("UL Li:eq (3)") |
Fourth element in the list (index starting from 0) |
: GT (no) |
$ ("UL li:gt (3)") |
List elements with index greater than 3 |
: LT (no) |
$ ("UL Li:lt (3)") |
List elements with index less than 3 |
: Not (selector) |
$ ("Input:not (: Empty)") |
All input elements that are not empty |
|
|
|
: Header |
$ (": Header") |
All heading elements |
: Animated |
|
All animated elements |
|
|
|
: Contains (text) |
$ (": Contains (' W3school ')") |
All elements containing the specified string |
: Empty |
$ (": Empty") |
All elements with No child (element) nodes |
: Hidden |
$ ("P:hidden") |
All hidden <p> elements |
: Visible |
$ ("table:visible") |
All the visible tables |
|
|
|
S1,s2,s3 |
$ ("Th,td,.intro") |
All elements with a matching selection |
|
|
|
[attribute] |
$ ("[href]") |
All elements with an HREF attribute |
[attribute=value] |
$ ("[href= ' # ']") |
The value of all href attributes equals "#" elements |
[attribute! =value] |
$ ("[href!= ' # ']") |
The value of all HREF attributes is not equal to the "#" element |
[attribute$=value] |
$ ("[href$= '. jpg ']") |
The value of all HREF attributes contains elements ending with ". jpg" |
|
|
|
: input |
$ (": input") |
All <input> elements |
: Text |
$ (": Text") |
All <input> elements of type= "text" |
:p Assword |
$ (":p Assword") |
All <input> elements of type= "password" |
: Radio |
$ (": Radio") |
All <input> elements of type= "Radio" |
: checkbox |
$ (": checkbox") |
All <input> elements of the type= "checkbox" |
: Submit |
$ (": Submit") |
All <input> elements of type= "submit" |
: RESET |
$ (": Reset") |
All <input> elements of type= "reset" |
: button |
$ (": Button") |
All <input> elements of type= "button" |
: Image |
$ (": Image") |
All <input> elements of type= "image" |
: File |
$ (": File") |
All <input> elements of type= "file" |
|
|
|
: Enabled |
$ (": Enabled") |
All the active input elements |
:d isabled |
$ (":d isabled") |
All disabled input elements |
: Selected |
$ (": Selected") |
All selected input elements |
: Checked |
$ (": Checked") |
All selected input elements |
Example: Select the value of the check box selected
$ ("Input[name= ' checkbox_list ']:checked"). each (function () {
parameter_id + = $ (this). Val () + "|";
});
Where Checkbox_list is the name value of each check box
Selectors in jquery