【问题标题】:Simple jQuery scroller - how to make it infinite?简单的 jQuery 滚动条 - 如何让它无限?
【发布时间】:2012-06-07 18:10:35
【问题描述】:

大家好,这是我的代码:

function scroll(obj) {
  $(obj).animate({top:'-'+$('li:nth-child(1)', obj)
        .outerHeight(true)}, 15000, 'linear', function(){
            $(obj).css({top:0});scroll(obj);
        });
}

只是想知道如何使它无限(保持循环或保持从上到下),而不是仅仅跳回顶部。

有什么想法吗?

【问题讨论】:

    标签: javascript jquery html css web


    【解决方案1】:
    function scrollDown(obj){
        obj.animate({top:'-'+$('li:nth-child(1)', obj).outerHeight(true)}, 15000, 'linear', function(){scrollUp($(this));});
    }
    
    function scrollUp(obj){
        obj.animate({top:0)}, 15000, 'linear', function(){scrollDown($(this));});
    }
    
    scrollDown($("#myObject"));
    

    【讨论】:

    • @user1294381 - 我建议你通过投票和/或接受这个答案来表示感谢。
    猜你喜欢
    • 2023-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-17
    • 2015-02-20
    相关资源
    最近更新 更多