In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "how to use siblings () of jquery". In daily operation, I believe many people have doubts about how to use siblings () of jquery. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to use siblings () of jquery". Next, please follow the editor to study!
Jquery siblings () is used to get all siblings of the selected element, traversing forward and backward along the siblings of the DOM element, returning all child elements that share the same parent element (except the selected element); the syntax "element object .siblings (filter)", whose parameters can be omitted, is used to narrow the search.
The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.
The jquery siblings () method is used to get all sibling elements of the selected element.
Sibling elements are elements that share the same parent element.
The siblings () method traverses forward and backward along the siblings of the DOM element, returning all child elements that share the same parent element (except the selected element).
Syntax format:
The $(selector) .siblings (filter) parameter description filter is optional. Specifies a selector expression that narrows the search for sibling elements.
Example 1: returns all siblings of each element with the class name "start"
$(document) .ready (function () {$("li.start"). Siblings (). Css ({"color": "red", "border": "2px solid red"}) }); .siblings * {display: block; border: 2px solid lightgrey; color: lightgrey; padding: 5px Margin: 15px } ul (parent node) li (last sibling node of class name "star") li (last sibling node of class name "star" ) li (sibling node) li (next sibling node of class name "star") li (next sibling node of class name "star")
In this example, we select all sibling elements of the li element with the class name "star".
Example 2: narrow the search (use two parameters to filter the search for sibling elements)
$(document) .ready (function () {$("li.start"). Siblings (".1") .css ({"color": "red", "border": "2px solid red"}) }); .siblings * {display: block; border: 2px solid lightgrey; color: lightgrey; padding: 5px Margin: 15px } ul (parent node) li (last sibling node with class name "star") li (last brotherly day with class name "star" Point) li (sibling node) li (next sibling node of class name "star") li (next sibling node of class name "star")
In this example, we narrow down the search results to return only sibling elements with class name "1" between li elements with class names "star" and "stop".
At this point, the study on "how to use siblings () of jquery" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.