我需要知道"owl-item active"的位置,我知道当前位置是2。总共有3张照片。
<div style="transform: translate3d(-825px, 0px, 0px); transition: all 0.25s ease 0s; width: 48675px;" class="owl-stage">
<div style="width: 825px; margin-right: 0px;" class="owl-item">
<div class="gallery-item" style="background-image: url('/image/144/1.jpg');"></div>
</div>
<div style="width: 825px; margin-right: 0px;" class="owl-item active">
<div class="gallery-item" style="background-image: url('/image/144/2.jpg');"></div>
</div>
<div style="width: 825px; margin-right: 0px;" class="owl-item">
<div class="gallery-item" style="background-image: url('/image/144/3.jpg');"></div>
</div>
</div>
如何使用Jquery .each()获取“owl-item active”位置?
我有这段代码,但找不到一种方法让代码告诉我,“owl-item active”在第2个位置。
$('.owl-stage .owl-item').each(function( index, currentElement ) {
console.log( index+1 );
//console.log( $(currentElement).find('div.owl-item.active') );
});
有人可以给我提示如何做这件事吗?