Dark Horse DAY16 jquery& hierarchy Selector

Source: Internet
Author: User

If you want to get specific elements through hierarchical relationships between DOM elements, such as descendant elements, child elements, neighboring elements, sibling elements, and so on, you need to use a hierarchy selector.

1,ancestor descendant

usage : $ ("form input"); return value collection element

Description: Matches all descendant elements under a given ancestor element. This is to be said below the "parent> child" area separate.

2 , Parent > Child
usage : $ ("form > Input"); return value collection element

Description: Matches all child elements under the given parent element. Note: To distinguish between descendants and child elements

3,prev + next

usage : $ ("label + input"); return value collection element

Description: Matches all next elements immediately following the Prev element

4,prev ~ siblings

usage : $ ("form ~ input"); return value collection element

Description: Matches all siblings elements after the Prev element. Note: The element that is after the match , does not contain the element, and siblings matches the elements of the prev sibling, whose descendants are not matched.

Note : ("prev ~ div") Selectors can only select the # prev " Elements behind the sibling elements ; and JQuery the methods in siblings () independent of front and back position , as long as it Peer Node You can choose

<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Dark Horse DAY16 jquery& hierarchy 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.