自动滚动

        $(document).ready(function(){
            scroll_f(".luck-tip .scroll-box",300);
    });
    //滚动
        var scrollIndex = 0;
        var Timer = null;
        function scroll_f(obj,time){
            clearInterval(Timer);
                var ul = $(obj).find("ul");
                var li = ul.children("li");
                var h = li.height();
                var index = 0;
                ul.css("height",h*li.length*2);
                ul.html(ul.html()+ul.html());  //复制一份当前ul内容
                    function run(){
                        if(scrollIndex>=li.length){
                        ul.css({top:0});
                        scrollIndex = 1;
                        ul.animate({top:-scrollIndex*h},time);
                    }
                    else{
                        scrollIndex++;
                        ul.animate({top:-scrollIndex*h},time);
                    }
                }
            Timer= setInterval(run,3000);
        }

 

posted @ 2022-03-31 14:46  吃惊夜夜  阅读(41)  评论(0编辑  收藏  举报