我这个:http: //jsfiddle.net/ZP76c/
我试图控制 jQuery 根据 index() 选择元素的范围,可能吗?
<div class="holder">
<div class="first">First</div>
<div class="second">Second</div>
<div class="first">First</div>
<div class="second">Second</div>
</div>
$('.holder div').click(function(){
alert($(this).index());
});
// desired behaviour: clicking the first 'first' div will alert: "0"
// clicking the second 'first' div, will alert: "1"
// so it takes the divs with a class of 'second' out of the index() calculation
// possible with jQuery .index()?