试图获取包含在活动部分中选择的类的锚标记的列表项的索引号
我想检索的 LI:
<li>
<a href="#" data-id="3" class="scene unchecked selected">The Health Care Delivery System</a>
</li>
在这个例子中,我应该得到一个索引 1
<ul>
<li>
<a href="#" class="scene expanded checked">Introduction</a>
</li>
<li class="active-section">
<a class="expanded">The Section 2</a>
<ul style="display: block;">
<li>
<a href="#" data-id="2" class="scene checked">Introduction</a>
</li>
<li>
<a href="#" data-id="3" class="scene unchecked selected">The Health Care Delivery System</a>
</li>
<li>
<a href="#" data-id="4" class="scene unchecked">Determining Payments from External Customers</a>
</li>
<li>
<a href="#" data-id="5" class="scene unchecked">Checkpoint</a>
</li>
</ul>
</li>
<li>
<a class="collapsed">Paying for Health Care</a>
<ul class="collapsed" style="">
<li>
<a href="#" data-id="6" class="scene unchecked">Health Care Systems</a>
</li>
<li>
<a href="#" data-id="7" class="scene unchecked">Find Savings with a Discount</a>
</li>
<li>
<a href="#" data-id="8" class="scene unchecked">Checkpoint</a>
</li>
<li>
<a href="#" data-id="9" class="scene unchecked">Defects in Ice Skate Pairs</a>
</li>
</ul>
</li>
<li>
<a href="#" data-id="22" class="collapsed scene unchecked">Summary</a>
</li>
</ul>
这是我尝试过的,但它不起作用
var innerIndex = $("li.active-section").index("li:has(a.selected)");