JQuery hierarchical selector Usage Analysis _ jquery

Source: Internet
Author: User
This article mainly introduces the usage of jQuery hierarchical selector. It analyzes the common usage skills of four hierarchical selector types and provides examples. For more information, see the HTML document, each element is always in a certain position on the DOM node tree, and there is always a hierarchical relationship between elements in the document hierarchy, such as the relationship between parent and child levels.

1. Child element Selector

Used to find all child elements under a given parent element. Syntax format:

The Code is as follows:

$ ("Parent-> chilid ");

2. Descendant element Selector

It is used to match all descendant elements under a given ancestor element. Syntax format:

The Code is as follows:

$ ("Ancestor descendant ");

3. Peer element Selector

It is used to match all next elements next to the prev element. Syntax format:

The Code is as follows:

$ ("Prev + next ")

4. Adjacent peer element Selector

Select all peer elements after an element. The syntax format is as follows:

The Code is as follows:

$ ("Prev ~ Siblings ")

Comprehensive instance:

The Code is as follows:





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.