'jQuery get index of nested element in relation to other nested elements with same class

First of all, sorry if the title isn't accurate, I can't think of a better title.

I have a similar structure like this:

<ol>
    <li>
        <ol>
            <li>1.</li>
            <li>2.</li>
            <li>3.</li>
            <li>4.</li>
        </ol>
    </li>
    <li>
        <ol>
            <li>1.</li>
        </ol>
    </li><li>
        <ol>
            <li class="active">1.</li>
            <li>2.</li>
        </ol>
    </li><li>
        <ol>
            <li>1.</li>
        </ol>
    </li>
</ol>

Now I want to grab the active class with a selector and want to get the index of this li in relation to all li's. So in this example I should get "5" if it is zero-based.

I tried different things with index(), closest(), parent() and so on with no success. I only get 0 for the active li because it's the first li in "his" ordered list. I think somehow this should be possible and I hope, some of you can give me a hint.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source