我此的控制範圍:http://jsfiddle.net/ZP76c/jQuery的index()函數
我試圖以控制jQuery的選擇元素)的範圍根據其離指數(,可能嗎?
<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()?