將圖像LI容器位置匹配到.slider-target偏移量。 ( '內', '.slider')。
HTML
<div class="slider-mask">
<ul class="slider-target">
<li>
<img src="img/01.jpg">
</li>
<li>
<img src="img/02.jpg">
</li>
<li>
<img src="img/03.jpg">
</li>
<li>
<img src="img/04.jpg">
</li>
</ul>
div class="clearfix"></div>
</div>
<div id="count"></div>
JQuery的
function matchimage() {
var targetposition = Math.abs($('.slider-target').position().left);
var matchthis = targetposition;
var visible = $('.slider-target li').filter(function() { return $(this).position().left == matchthis }).index();
var total = $('.slider img').length;
$("#count").html((visible + 1) + ' of ' + total);
}
你有沒有嘗試ATLEAST'變種圖像= $長度;' – adeneo
什麼碼你有?有多種顯示旋轉木馬的方法。 – Bot