Home > Web Front-end > JS Tutorial > jquery siblings usage summary

jquery siblings usage summary

小云云
Release: 2017-11-17 11:29:37
Original
2138 people have browsed it

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)
Copy after login

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>
Copy after login
 $("div").siblings().html();
Copy after login

The result will be output:

<p>Hello</p>    
<p>How are you!</p>
Copy after login

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>
Copy after login
$("div").siblings(".selected").html();
Copy after login

The result will be output:

<p class="selected">www.phpernote.com</p>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template