"Basic jquery Tutorial (fourth edition)" Learning notes

Source: Internet
Author: User

2nd Chapter SELECT Element

1. Use the $ () function

The $ () function is actually creating a jquery object. This function takes a CSS selector as a parameter, acts as a factory, and returns a JQuery object that contains the corresponding elements in the page. All selectors that can be used in a style sheet can be passed to this function, and then the jquery method can be applied to the set of matching elements.

In jquery, dollar sign $ is actually the "alias" of the identifier jquery.

2. Selectors

1. Base Selector $ (' P ')//get all the elements labeled P$ ('. Class ')//get all classes of class elements$ (' #id ')//gets the element with ID as ID                    //and other selectors in the CSS2The . Property Selector $ (' Img[alt] ')//Select all image elements with an ALT attribute    //^ represents the value at the beginning of the string, which represents the value at the end of the string. * indicates that the value to be matched can appear anywhere in the string! Indicates that the value is reversed$ (' a[href^= ' mailto: "])//Select all mailto in page: Link$ (' a[href$= '. pdf "])//Select links to all PDF documents on the page$ (' a[href^= ' http "][href*=" Henry "])//Select the href attribute to start with HTTP and include Henry's Elements anywhere3. Custom Selectors $ (' Div.horizontal:eq (1) ')//gets the second element in a collection$ (' Tr:even ')//select Odd rows. The odd line is because the first row is numbered 0.$ (' Tr:nth-child (odd) ')//select odd lines.: Nth-child () is the only selector in JQ that counts from 1$ (' Tr:contains (Henry) ')//selects elements based on context content. Contains selectors are case-sensitive4. The form-based selector $ (' Input[type= ' Radio "]:checked")//You can select all the selected radio buttons$ (' input[type= "text"]:d isabled ')//Select a disabled text entry field

More form-based selectors

    : Input    : Button    : Enabled    :d isabled    : checked:selected

3. Dom Traversal method

"Basic jquery Tutorial (fourth edition)" Learning notes

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.