Home >Web Front-end >Front-end Q&A >What does jquery sibling mean?
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.
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!