开发者

How to get the index of the ACTIVE CHILD div of my container with jQuery?

<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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜