Key Points of jQuery (1) jQuery selector _ jquery

Source: Internet
Author: User
Sharp jQuery key points (1) jQuery selector. For more information about jquery learning, see. 1. Basic Selector

$ (# Id)
Matches an element based on the given id.
$ (. Class)
Matches the element based on the given class name.
$ (Element)
Match an element based on the given element name
$ (*)
Match All elements
$ (Selector1, selector2,..., selectorN)
Returns the elements matched by each selector together.

2-level Selector

$ ("Ancestor descendant ")
Select all descendant (descendant) elements in ancestor
$ ("Parent> child ")
Select only child (sub-level) elements under the parent element, which is different from $ ("ancestor descendant"). The former Selects all descendant elements (including but not limited to sub-levels)
$ ('Prev + next ')
Select the next element next to the prev Element
$ ('Prev ~ Siblings ')
Select the next element after the prev Element

3. Filter Selector

3.1 basic filter Selector

$ ("Selector: first ")
Select the first element
$ ("Selector: last ")
Select the last element
$ ("Selector: not (selector2 )")
Removes all elements that match the given selector.
$ ("Selector: even ")
Select all the elements with an even index. The index starts from 0.
$ ("Selector: odd ")
Select all the elements with an odd number of indexes. The index starts from 0.
$ ("Selector: eq (index )")
Select the element whose index is equal to the index. The index starts from 0.
$ ("Selector: gt (index )")
Select the element whose index is greater than the index, and the index starts from 0.
$ ("Selector: lt (index )")
Select the element whose index is smaller than the index, and the index starts from 0.
$ (": Header ")
Select All title elements, such as h1, h2, h3, etc.
$ (": Animated ")
Select all elements of the animation being executed

3.2 content filter Selector

$ (": Contains (text )")
Select an element with text content as "text"
$ (": Empty ")
Select an empty element that does not contain child elements or text
$ (": Has (selector2 )")
Select the element containing the element matched by the selector
$ (": Parent ")
Select an element that contains child elements or text

3.3 visibility filter Selector

$ (": Hidden ")
Select all invisible elements
$ (": Visible ")
Select all visible elements

3.4 attribute filter Selector

$ ("Selector [attribute]")
Select the element with this attribute
$ ("Selector [attribute = value]")
Select an element whose attribute value is value
$ ("Selector [attribute! = Value] ")
Select an element whose attribute value is not equal to value
$ ("Selector [attribute ^ = value]")
Select an element whose attribute value starts with value.
$ ("Selector [attribute $ = value]")
Select the element whose attribute value ends with value.
$ ("Selector [attribute * = value]")
Select the element whose attribute value contains value.
$ ("Selector [selector2] [selectorN]")
Combine the attribute selector into a composite attribute selector to meet multiple conditions. For example, if $ ("p [id] [title $ = 'test']") is selected to have the property id, and the property title ends with "test ",

Element

3.5 child element filter Selector

$ (": Nth-child (index/even/odd/equation )")
Select the index sub-element or parity element under each parent element. The index starts from 1.
$ ("Selector: first-child ")
Select the first child element of each parent element.
$ ("Selector: last-child ")
Select the last child element of each parent element.
$ ("Selector: only-child ")
If an element is the only child element in its parent element, it will be matched. If the parent element contains other elements, it will not be matched.

3.6 form object attribute filter Selector

$ ("Selector: enabled ")
Select all available elements
$ ("Selector: disabled ")
Select all unavailable Elements
$ ("Selector: checked ")
Select All selected elements (radio, checkbox)
$ ("Selector: selected ")
Select All selected option Elements)

4. Form Selector

$ (": Input ")
Select All,,,Element$ (": Text ")Select all single-row text boxes$ (": Password ")Select all password boxes$ (": Radio ")Select all single-region$ (": Checkbox ")Select All check boxes$ (": Submit ")Select all submit buttons$ (": Image ")Select All image buttons$ (": Reset ")Select all reset buttons$ (": Button ")Select All buttons$ (": File ")Select All upload Domains$ (": Hidden ")Select all invisible elements

Related Article

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.