jquery Hierarchy Selector

Source: Internet
Author: User

About the hierarchy selector.
$ ("Parent > Child")
Selects all the immediate child elements that are specified in the "parent" element.
Parent: Any valid selector.
Child: The selector used to filter sub-elements

$ (function () {
$ ("Ul.myul > Li"). CSS ("Border", "2px solid Red");
Put UL with. Myul Select the following Li label to add a border.
});

$ ("ancestor descendant")
Selects all descendant elements of a given ancestor element
Ancestor: any valid selector;
Descendant: A selector to filter the child elements;

$ (function () {
$ ("form input"). CSS ("Border", "2px solid green")
Add a border to all input tags in a form
});

$ ("Prev+next")
Select all the "next" elements immediately following the "prev" element.
Prev Any valid selector
Next is used to filter the selector following "prev"

$ (function () {
$ ("label + Input"). CSS ("Border", "2px solid Red")
Add all the input tags immediately following the label with a border
});

$ ("prev ~ siblings")
Select any one of the valid selectors to follow for all sibling elements. They have the same parent element.
Prev Any valid selector
Siblings a selector used to filter the sibling selector after the first selector.

$ (function () {
$ ("#prev ~ div"). CSS ("Border", "2px solid Red");
Add a border to the sibling div tag behind the prev Selector
})

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.