Common jQuery selector aggregation and jquery Selector

Source: Internet
Author: User

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 ")

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.