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