<body><div class="titTab"> ???<span>低</span> ???<span>中</span> ???<span class="select">高</span></div>
<input type="button" value="获取下标" class="target"/>
</body>
$(".target").click(function(){ ???//方法一 注意空格与非空格 ???var index = $(‘.titTab span.select‘).index(); ???//方法二 ???//var index = $(‘.titTab .select‘).index(); ???alert("index:"+index);//弹出index:2
});
js获取标签下标
原文地址:http://www.cnblogs.com/yinyl/p/7885579.html