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?
$('li').click(
function () {
alert($(this).index());
});
Demo here: http://jsfiddle.net/KyTP5/
Note that this gives you the zero-based index.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With