Find list item with class and get its list position in jQuery

jquery

Solution

$('li.pageItem').index($('li.current')[0]);

will return 2, just add +1 if you want the index starting from 1.

Problem

I have a list like this: ``` <ul> <li class="pageItem">1</li> <li class="pageItem">2</li> <li class="pageItem current">3</li> <li class="pageItem">4</li> <li class="pageItem">5</li> </ul> ``` I want to calculate the list item position of .current. In this case it would be 3. Just to make things clear: I don't want the X & Y position of the element. Just what number in the line it has. Thanks!

Original source