<div class="top">
<div class="hp_class">
This is div1.
</div>
<div>
<form id="newsletter" name="myForm" method="post">
<div class="hp_rt">
<div class="subscribe subs_failure">Subscribe now</div>
</div>
</form>
</div>
<div class="hp_class">
This is div3.
</div>
</div>
div
我需要标签的索引,例如,如果我点击
Subscribe now
,我需要它的索引为 2我试过的代码是
$('.hp_rt>.subscribe').click(function(){
var div_count=$(this).parent('.hp_promo_rt').parents('div').index($(this).parent('.hp_rt').parents('div'));
alert(div_count);
});