JQuery Select Element Selection
jquery Selector
ID selector (js generally try to use the ID selector, the most Efficient)
$ ("#id"). HTML ();
Class Selector
$ (". className"). Text ();
Tag Selector
$ (' P '). "click ()
Property Selector
$ ("li[id]"), $ ("li[id= ' link"). fadeIn ();
Hierarchy Selector
$ ("li. link"). Show ();
Parent-child Selector
$ ("ul > Li")
Pseudo class Selector
$ ("p:first")
$ ("ul Li:eq (3)")
Form Selector
$ (": Text")
$ (": Checkbox")
$ (": Checked")
Selector Rollup
* $ ("*") 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") <p> element
: Last $ ("p:last") final <p> element
: Even $ ("tr:even") all even <tr> elements
: Odd $ ("tr:odd") all odd <tr> elements
: EQ (index) $ ("ul li:eq (3)") in the list of fourth elements (index starting from 0)
: GT (no) $ ("ul li:gt (3)") lists elements with index greater than 3 greater than
: Lt (no) $ ("ul li:lt (3)") lists the element less than 3 of the index lesser than
: 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 ')") contains all elements of the specified string
: Empty $ (": Empty") all elements of No child (element) node
: Hidden $ ("p:hidden") all hidden <p> elements
: Visible $ ("table:visible") for all the viewable tables
S1,S2,S3 $ ("th,td,.intro") All elements with a matching selection
[attribute] $ ("[href]") All elements with href attribute
[attribute=value] $ ("[href= ' # ']") all href attribute values equal to "#" elements
[attribute!=value] $ ("[href!= ' # ']") all href attribute values are not equal to "#" elements
[attribute$=value] $ ("[href$=. Jpg]") all href attribute values contain elements that end with ". jpg"
: Input $ (": Input") all <input> elements
: Text $ (": Text") all type= "text" <input> elements
:p Assword $ (":p Assword") all type= "password" <input> elements
: Radio $ (": Radio") all type= "radio" <input> elements
: CheckBox $ (": Checkbox") all the <input> elements of the type= "checkbox"
: Submit $ (": Submit") all type= "submit" <input> elements
: Reset $ (": Reset") for all type= "reset" <input> elements
: Button $ (": Button") for all type= "button" <input> elements
: Image $ (": Image") all the <input> elements of the type= "image"
: File $ (": File") all the <input> elements of the type= "file"
: Enabled $ (": Enabled") all active input elements
:d isabled $ (":d Isabled") all disabled input elements
: Selected $ (": Selected") all selected input elements
: Checked $ (": Checked") all selected input elements
jquery Selection method
Get parent Element
$ (selector). Parent (); Get Direct Parent
$ (selector). Parents (' p '); Gets all the parent elements until the HTML
Get the elements of descendants and descendants
$ (selector). Children (); Get Direct child elements
$ (selector). Find ("span"); Get all the descendant elements
The Find method may be used More.
Gets the element of the sibling
$ (selector). siblings ()//all sibling nodes
$ (selector). Next ()//next node
$ (selector). Nextall ()//all nodes behind
$ (selector). prev ()//front one sibling node
$ (selector). Prevall ()//front of all sibling nodes
Filtration method
$ ("div p"). Last (); Take the last element
$ ("div p"). First (); Take the first element
$ ("p"). eq (1); Go to nth Element
$ ("p"). Filter (". intro"); filter, Select all p tags with the. intro class
$ ("p"). Not (". intro"); It's just the opposite of the Filetr.
The selection elements and methods of JQuery