Common jQuery selector aggregation and jquery Selector
Basic Element Selector
Copy codeThe Code is as follows:
$ ("P ")
$ ("P. ii") select all p elements of class = ii
$ ("P # demo") Select the first p element of id = demo.
Layered Selector
Copy codeThe Code is as follows:
$ ("Div input") All input values under div
$ ("Div> input ")
Basic Condition Selector
Copy codeThe Code is as follows:
$ ("P: first ")
$ ("P: last ")
$ ("Tr: even") Select an even row
$ ("Tr: odd") odd
$ ("Input: not (: checked)") select all selected elements
$ ("Tr: eq (1)") table with an index value of 1
$ ("Tr: gt (0)") greater than 0
$ ("Tr: lt (0)") less than 0
$ (": Header") select all title Elements
$ (": Animated") animation being executed
Content condition Selector
Copy codeThe Code is as follows:
$ ("Div: constains ('ddd ')") Select the layer element that contains the ddd text
$ ("Td: empty") Select a table unit that does not contain text or child elements
$ ("Div: has (p)") Select the Layer Element containing the section element
$ ("Td: parent") Select a table unit that contains child elements or text
Visibility condition Selector
Copy codeThe Code is as follows:
$ ("Tr: hidden") // select all hidden tables
$ ("Tr: visible") select all visible tables
Attribute Selector
Copy codeThe Code is as follows:
$ ("Div [id]") layer with id attribute
$ ("Input [name =''] ") input attribute name =''
$ ("Input [name! = '']")
$ ("Input [name ^ =''] ") Select a form input element with the name attribute and whose value is'' as the starting content
$ ("Input [name $ =''] ") Select a form input element with the name attribute and the value'' as the End Content
$ ("Input [name * =''] ") Select a form input element with the name attribute and value ''.
$ ("Input [id] [name $ =''] ") Select an input form element whose values with the id and name attributes end''
Child element Selector
Copy codeThe Code is as follows:
$ ("Ul li: nth-child (2)") Select the second list item
$ ("Ul li: nth-child (even )")
$ ("Ul li: nth-child (odd )")
$ ("Ul li: nth-child (3n )")
$ ("Ul li: first-child ")
$ ("Ul li: last-child ")
$ ("Ul li: only-child") Select a list and only one list item appears.
Form element Selector
Copy codeThe Code is as follows:
$ ("Input") select all input textarea select buttons and other elements
$ (": Text") text line
$ (": Password ")
$ (": Radio ")
$ (": Checkbox ")
$ (": Submit ")
$ (": Image ")
$ (": Reset ")
$ (": Button ")
$ (": File ")
$ (": Hidden ")
Form attribute Selector
Copy codeThe Code is as follows:
$ ("Input: enabled") // select all available
$ ("Input: disabled ")
$ ("Input: checked ")
$ ("Select: option: selected ")