By default jQuery always returns the highest index when the selector returns more than one element, as in the example below:
<ul>
<li>1</li>
<li>2</li>
<li class="error">3</li>
</ul>
<ul>
<li class="error">4</li>
<li>5</li>
<li>6</li>
</ul>
$('li').click(function(){
alert($('.error').parents('ul').index());
})
I also tried this:
alert($('.error')[0].parents('ul').index());
However, this statement returns:
TypeError: undefined is not a function