<div id="container">
<div class="active">
<div class="active"></div>
</div>
<div>
<开发者_StackOverflow/div>
</div>
How to write such a container?
Use .index()
without parameters to get it's (0
-based) index amongst siblings, like this:
var index = $("#container .active").index();
You can test it out here. For your example markup, it would be 0
.
精彩评论