I've got a problem with .index()
function in jQuery.
Outline of DOM:
<div class="one">
<div class="two">
<div class="three"></div>
<div class="three"></div>
<div class="three"></div>
</div>
<div class="threeB"></div>
<div class="threeB"></div>
<div class="threeB"></div>
</div>
<div class="one">
<div class="two">
<div class="three"></div>
<div class="three"></div>
</div>
<div class="threeB"></div>
<div class="threeB"></div>
</div>
<div class="one">
<div class="two">
<div class="three"></div>
<div class="three"></div>
<div class="three"></div>
</div>
<div class="threeB"></div>
<div class="threeB"></div>
<div class="threeB"></div>
</div>
According to which of three
s in two
a user clicks, one of the threeB
s are displayed. I wanted to do this with .index()
function, but it fails for all but the first ones. In the second one
class, the two three
s have indexes 3 and 4 (instead of desired 0 and 1). On the other hand, .eq()
for threeB
s seems to work as desired.
Any neat way to solve this without having to count how many three
s were there before the div
in question?