The parent and sibling lookup in the use of the process is very frequent, the following for you to introduce how jquery is implemented, interested friends can refer to the following:
Jquery.parent (expr) to find a Father node, you can pass in expr for filtering, such as $ ("span"). Parent () or $ ("span"). Parent (". Class").
Jquery.parents (expr), similar to jquery.parents (expr), but finds all ancestor elements, not limited to the parent element.
Jquery.children (expr). Returns all child nodes, this method only returns a direct child node and does not return all descendant nodes.
Jquery.contents (), returns all of the following, including nodes and text. The difference between this method and children () is that including blank text is also returned as a jquery object, and children () returns only the node.
Jquery.prev (), returns the previous sibling node, not all sibling nodes.
Jquery.prevall (), returning all previous sibling nodes.
Jquery.next (), returns the next sibling node, not all sibling nodes.
Jquery.nextall (), returns all the sibling nodes that follow.
Jquery.siblings (), returns the sibling node, not before or after.
Jquery.find (expr) is completely different from jquery.filter (expr). Jquery.filter () is filtered from the initial set of JQuery objects, and the returned result of Jquery.find () does not have the contents of the initial collection, such as $ ("P"), Find ("span"), which is the start of the element, equivalent to $ ("p Span ").
jquery parent and sibling element lookup introduction