Reputation: 4847
I am trying to find the index of the following element
<ol id="parent">
<li><a></a></li>
<li><a class="index_of_this"></a></li>
<li><a></a></li>
<li><a></a></li>
</ol>
But I keep getting -1
$('#parent a.index_of_this')
thank you for your help
Upvotes: 1
Views: 230
Reputation: 630587
To get an index of 1
, do this:
$("a.index_of_this").parent().index(); //1
//or this...
$("#parent").children(":has(.index_of_this)").index(); //1
Upvotes: 1