开发者

How to get child-index of element in prototype

开发者 https://www.devze.com 2023-01-27 08:52 出处:网络
If I have a structure like this: <ul> <li class=\"golden-delicious\">Golden Delicious</li>

If I have a structure like this:

<ul>
   <li class="golden-delicious">Golden Delicious</li>
   <li class="mutsu">Mutsu</li>
   <li class="mcintosh">McIntosh</li>
   <li class="ida-r开发者_JAVA技巧ed">Ida Red</li>
</ul>

and a selector

$$('li.mutsu')[0]

that returns an element, how can I get the index of this element within its parent child collection? I need the index value "1" of li.mutsu.


You could use .previousSiblings().size()

0

精彩评论

暂无评论...
验证码 换一张
取 消