Below is a list of the methods of Jqery node lookup:
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 parent elements
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, it will also be used as a
The jquery object returns, children () returns only the node
Jquery.prev (), return to the previous sibling node, not all sibling nodes
Jquery.prevall (), returns all previous sibling nodes
Jquery.next (), returns the next sibling node, not all sibling nodes
Jquery.nextall (), returns all subsequent sibling nodes
Jquery.siblings (), back to sibling nodes, no points
Jquery.find (expr) is completely different from jquery.filter (expr). Jquery.filter () is a partial filter from the initial set of jquery objects, while the Jquery.find ()
The return result, will not have the contents of the initial collection, such as $ ("P"), Find ("span"), is starting from the P element, equivalent to $ ("P span")
Give me a practical example.
Here is an HTML, the beginning of the "Li", to find the "checkbox"
<Liclass="List-group-item Completed_item">
<Divclass="Text_holder">
Reerytre
<Divclass="Btn-group pull-right">
<Buttonclass="Delete btn btn-warning">Delete</Button>
<Buttonclass="Edit btn btn-success">Edit</Button>
</Div>
</Div>
<Divclass="checkbox">
<label><input type="checkbox"class="Pull-right"></label>
</Div>
</Li>
Li = $ (
< Span style= "font-family: Microsoft Ya Hei" > to find: <input type=" checkbox "class=" Pull-right ";
Method 1:
checkbox = Li.children (": First"). Next (). Children (": First"). Children (": first");
Method 2:
Li . Find (' input ');
Just write it here ...
Copyright NOTICE: This article for Bo Master original article, welcome reprint, reproduced please indicate the source.
jquery's parent, son, and brother node lookup method