jquery轮播图最后一张图片如何无缝轮播到第一张图片?(轮播顺序应和前面一样,即从左往右),代码如下:

2025-05-18 18:31:28
推荐回答(1个)
回答1:

$(document).ready(function() {
            var timer = null;
            var pic = $(".pic");
            var oUl = pic.children("ul");
            var aImg = pic.find("img");
            var imgWidth = parseFloat(pic.css("width")) || pic.prop("offsetWidth");
            oUl.css("width", imgWidth * aImg.length + 'px');
            var i = 0;
            timer = setInterval(function() {
                oUl.animate({
                    "left": "-" + imgWidth + 'px'
                }, 500, function(){
                 oUl.children("li:first").insertAfter(oUl.children("li:last"));
                 oUl.css("left", 0);
                });
            }, 1000);
        });