What does jquery sibling mean?

藏色散人
Release: 2021-11-15 10:56:15
Original
2561 people have browsed it

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

Parameters

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

Example

Return all sibling elements of each

  • element with class name "start":

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

    Result:

    ul (parent)
    li (sibling)
    li (sibling)
    li (sibling with class name "start")
    li (sibling)
    li (sibling)
    Copy after login

    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!

  • 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