jquery siblings is used to obtain the siblings of each element in the matching set. siblings() gets the siblings of each element in the matching set, optionally filtered by a selector. Next, I will introduce jQuery to you through this article. Detailed explanation of siblings() usage examples, friends in need can refer to it.
Syntax
.siblings(selector)
Note: You can further filter through the optional parameter selector (selector) that follows.
Example:
Find all sibling elements of each div.
<p>Hello</p> <div> <span>www.phpernote.com</span> </div> <p>How are you!</p>
$("div").siblings().html();
The result will be output:
<p>Hello</p> <p>How are you!</p>
Example:
Find the elements with the class name selected among all the sibling elements of each div.
<div> <span>Hello</span> </div> <p class="selected">www.phpernote.com</p> <p>How are you!</p>
$("div").siblings(".selected").html();
The result will be output:
<p class="selected">www.phpernote.com</p>
The above is a detailed explanation of jQuery siblings() usage examples. I hope it will be helpful to everyone!
Related recommendations:
Usage details of jQuery.siblings() function
Detailed explanation of jQuery.siblings() function
Summary of usage of siblings() in jQuery
The above is the detailed content of jquery siblings usage summary. For more information, please follow other related articles on the PHP Chinese website!