In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the jquery how to find the number of brother elements of the relevant knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that everyone after reading this jquery how to find the number of brother elements article will have a harvest, let's take a look.
Get method: 1, use siblings () to get the siblings of the specified element, syntax "specify element .siblings ()", will return a jQuery object containing all siblings; 2, use the length attribute to count and return the number of elements in the jQuery object, syntax "specify object .length".
The operating environment of this tutorial: windows7 system, jquery1.10.2 version, Dell G3 computer.
Jquery's method of finding the number of sibling elements
1. Use the siblings () method to get all sibling elements of the selected element
This method traverses forward and backward along the siblings of the DOM element.
Specify element .siblings ()
A jQuery object containing all sibling elements is returned.
2. Use the length attribute to get the number.
The length property counts the number of elements in the jQuery object and returns.
Specify the object .length
Implementation example:
.siblings, .siblings * {display: block; border: 2px solid lightgrey; color: lightgrey; padding: 5px; margin: 15px } $(document) .ready (function () {$("button") .click (function () {$("h3") .siblings () .css ("border") "2px solid red") var len=$ ("h3"). Siblings (). Length Console.log ("the number of sibling elements is:" + len);});}); div (parent)
P (sibling element)
Span (sibling) h3 (this element) h4 (sibling)
P (sibling element)
Get the number of sibling elements
This is the end of the article on "how to find the number of brother elements in jquery". Thank you for reading! I believe you all have a certain understanding of the knowledge of "how to find the number of brother elements in jquery". If you want to learn more, you are welcome to follow the industry information channel.
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.