Suppose I have the following HTML:
<div id="Container">
<div class="TheClass"></div>
<div class="TheOtherClass"></div>
<div class="TheClass"></div>
<div class="TheOtherClass"></div>
<div class="TheClass"></div>
<div class="TheOtherClass"></div>
</div>
As you can see, I have two classes alternating. I want to pass the index of the class TheClass in terms of its occurrence inside the container.
If I write:
$('#Container').on({
click: function () { SomeFunction($(this).index()); }
}, '.TheClass');
and click on the last element TheClass, the parameter passed will be 5 but I want to receive 3 because the last TheClass element is the third occurrence. How can I do that?