Golden Delicious

How to get the child index of an element in a prototype

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-red">Ida Red</li>
</ul>

and selector

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

which returns an element, how can I get the index of this element in my parent child collection? I need the index value "1" li.mutsu.

+3
source share
1 answer

you can use .previousSiblings().size()

+12
source

Source: https://habr.com/ru/post/1777639/


All Articles