jquery Chapter II Selector

Source: Internet
Author: User
Tags tag name

I. Basic Selector

The basic selector is the most commonly used selector for jquery, and is the simplest selector to find DOM elements by element ID, class tag name (only once in a Web page, ID is unique, but class allows reuse)

1.id Selector

Usage: $ ("#id名称"); Returns a collection of the constituent elements of a single element

2.class (class selector)

Usage: $ (". Class"); Returns the collection element class is the style name

3.element (Tag Selector)

Usage: $ ("Span,p,div"); Returning a collection element

4.* All selectors

Usage: $ ("*"); Returns a collection element that matches all elements

Two. Hierarchy Selector

Base Filter Selector (also the most commonly used filter selector)

: Not (SELECT) Usage: $ (input:not (select)); Returns the collection element description: Removes all elements that match the given selector. It's kind of like "non."

: First finds element one

: last element found

: Odd matches the element labeled base

: Even matches an even-numbered element

: eq (subscript) matches the element that made the subscript

: GT (Subscript) match index value is greater than the element to be set (not including itself)

: The LT (subscript) match index value is less than the element of the given small label (does not contain itself)

Content Filter Selector

: Contains ("text content") matches whether the element contains the text content of the specified text

: Has (tag element) matches the element that contains the element that the selector matches

: Empty matches element content to null element

:p arent matches elements that contain child elements or text

Attribute Filter Selector

[Attribute=value]: The property filter Selector is the element's properties to get the corresponding element

For example: $ ("Input[name= ' chk ']"). attr ("Checked", true); Is the checked of the check box named Chk returns a collection property changed to True

Visibility Filter Selector

: Hidden Filters hidden Elements (type= "hidden", css:display= "name")

: Visible Filter Elements

child element Filter Selector

: Nth-child (index/even/odd/equation) Note: The index value here starts at 1, and the EQ is starting from 0

: First-child Find First child element

: Last-child found last child element

: Only-child matches elements with only one child element

Form object property Filter Selector

:d isabled filtering for elements that are not available

: Enabled filters available elements

: Checked Filter selected check box

: Selected filter drop-down box selected element

    

jquery Chapter II Selector

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.