Find the clicked li number
Posted
by fire
on Stack Overflow
See other posts from Stack Overflow
or by fire
Published on 2010-05-28T08:31:34Z
Indexed on
2010/05/28
8:41 UTC
Read the original article
Hit count: 161
JavaScript
|jQuery
I have a standard list...
<ul>
<li><a href="#">blah 1</a></li>
<li><a href="#">blah 2</a></li>
<li><a href="#">blah 3</a></li>
<li><a href="#">blah 4</a></li>
</ul>
And my jQuery:
$('ul li a').live('click', function() {
var parent = $(this).parent('li');
});
What I want to find out is the parent li's position in the list of the clicked link e.g. clicking on blah 3 would give me 2, blah 4 would give 3 etc.
Any ideas?
© Stack Overflow or respective owner