find element nth position within parent

jquery

Solution

$('li').click(
    function () {
        alert($(this).index());
    });

Demo here: http://jsfiddle.net/KyTP5/

Note that this gives you the zero-based index.

Problem

If I have this: ``` <ul> <li><a href="#"></a>a</li> <li><a href="#"></a>b</li> <li><a href="#"></a>c</li> <li><a href="#"></a>d</li> <li><a href="#"></a>e</li> </ul> ``` And lets say I clicked on third li item (with a content of 'c'). How Could I get the info this item is third within 'ul' parent?

Original source