开发者

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

开发者 https://www.devze.com 2023-01-31 05:55 出处:网络
<div id=\"container\"> <div class=\"active\"> <div class=\"active\"></div> </div>
<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

精彩评论

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

关注公众号