"JQuery" selector
Information: W3school http://www.w3school.com.cn/jquery/jquery_ref_selectors.asp
1. Tag Selector: $ ("P")--all P tags
2. ID Selector: $ ("#txtid")--id = txtid Element
3. Class Selector: $ (". Pclass")--class = Pclass element
4. Property Selector: $ ("[href= ' lnk ']")--href = lnk element
Selector | Selector
Example |
Select |
* |
$("*") |
All elements |
#ID |
$ ("#id") |
id= "id" lookup |
. class |
$ (". Intro") |
class= Elements of "Intro" |
Element |
$ ("P") |
All <p> elements |
. class. class |
$ (". Intro.demo") |
All class= "Intro" and Class= "demo" Elements |
This |
$ (This) |
Their own |
: 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 |
"JQuery" selector