Home >Web Front-end >Front-end Q&A >What does jquery sibling mean?

What does jquery sibling mean?

藏色散人
藏色散人Original
2021-11-15 10:56:152594browse

jquery sibling is a jquery method that returns all sibling elements of a selected element. Its usage syntax is such as "$(selector).siblings(filter)". The parameter filter specifies the scope of searching for sibling elements. Selector expression.

What does jquery sibling mean?

The operating environment of this article: windows7 system, jquery3.2.1 version, DELL G3 computer

#What does jquery sibling mean?

jQuery siblings() method:

siblings() method returns all sibling elements of the selected element.

Sibling elements are elements that share the same parent element.

DOM tree: This method traverses forward and backward along the sibling elements of the DOM element.

Tip: Please use the prev() or next() method to narrow the scope of searching only the previous sibling element or the next sibling element.

Syntax

$(selector).siblings(filter)

Parameters

filter Optional. Specifies a selector expression that narrows the search for sibling elements.

Example

Return all sibling elements of each 25edfb22a4f469ecb59f1190150159c6 element with class name "start":

$(document).ready(function(){
    $("li.start").siblings().css({"color":"red","border":"2px solid red"});
});

Result:

ul (parent)
li (sibling)
li (sibling)
li (sibling with class name "start")
li (sibling)
li (sibling)

Recommended learning: "jquery video tutorial"

The above is the detailed content of What does jquery sibling mean?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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