2013-04-23 112 views
0

我有以下代码,它的行为有所不同CodePenJSFiddle和在我的浏览器中。它只能在CodePen中完美运行。jQuery垂直文本滚动

本质上,我希望它从上到下无限滚动而不停止。

下面是动作的代码,http://jsfiddle.net/qmFD3/http://codepen.io/anon/pen/fiaql

function scroller() { 
    $('#honor-roll ul').animate({ 
    top: '-=' + $('#honor-roll ul li:last').height() 
    }, 1000, 'linear', function() { 
    var offset = $('#honor-roll ul li:last').offset().top; 
    console.log(offset); 
    if (offset <= 2000) { 
     $('#honor-roll ul').css("top", 0); 
     $('#honor-roll ul li:last').after($('#honor-roll ul li:first').detach()); 
    } 
    }); 
} 
$(document).ready(function() { 
    setInterval('scroller()', 200) 
}); 

回答

1

在的jsfiddle控制台说的这两个例子:

Uncaught ReferenceError: scroller is not defined 
(anonymous function)