Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
所以我的代码是这样生成的(当单击 a 时,它会将活动类添加到当前类):
<div> <a href="#"></a> <a href="#"></a> <a href="#" class="active"></a> <a href="#"></a> ... </div>
如何获取活跃的标签索引?
你可以使用.index():
.index()
$("a.active").index()
jsFiddle 中的示例:http: //jsfiddle.net/dvirazulay/V25un/