1.chirldren ()
Html:
<body>
<p></p>
<ul>
<li></li>
</ul>
</body>
jquery Code:
var bodylength=$ (' body '). Chirldren (). length; Gets <body> the number of child elements below, with a result of 2
var plength=$ (' P '). Chirldren (). length;//gets the number of child elements under the <p> tag, the result is 0
var ullength=$ (' ul '). Chirldren (). length;//gets the number of child elements under the <ul> tag, the result is 1
Attention! The Chirldren () method considers only child elements regardless of any descendant elements.
2.next ()
Html:
<body>
<p></p>
<ul>
<li></li>
</ul>
</body>
jquery Code:
var $p 1=$ (' P '). Next ();//Get the sibling elements immediately following the <p> element
Results:
<ul>
<li></li>
</ul>
3.prev ()
Html:
<body>
<p></p>
<ul>
<li></li>
</ul>
</body>
jquery Code:
var $ul =$ (' ul '). Prev (); Get the sibling elements immediately before the <ul> element
Results:
<p></p>
4.siblings ()
Html:
<body>
<p></p>
<span></span>
<ul>
<li></li>
</ul>
</body>
jquery Code:
var $span =$ (' span '). siblings ();//Get <span> tagged sibling elements
Results:
<p></p>
<ul>
<li></li>
</ul>
5.closest ()
Used to get the closest matching element. First, check if the current element matches, if the match returns the ability directly, the mismatch will look up the parent element, step up until the element matching the selector is found, and return an empty jquery object if nothing is found.
6. Other: Find (), filter (), Nextall (), Prevall (), parent (), parents ()
jquery Traversal node