Using jQuery, I'd like to be able to get the index of the li where the contained anchor tag's HREF equals "#All". (In this case the correct result would be 3)
<div id="tabs">
<ul>
<li><a href="#CPU"><span>CPU</span></a></li>
<li><a href="#Pickup"><span>Pickup</span></a></li>
<li><a href="#Breakfix"><span>Breakfix</span></a></li>
<li><a href="#All"><span>All</span></a></li>
</ul>
</div>
I have tried:
$("#tabs ul").index($("li a[href='#All']"))
...with no luck. What am I doing wrong?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…