在線演示:http://demo.jb51.net/js/2012/callboard/
jQuery代码
//第二版:Newton 改造
(function (win){
var callboarTimer;
var callboard = $(' #callboard');
var callboardUl = callboard.find('ul');
var callboardLi = callboard.find('li');
var initHeight = callboardLi.first().outerHeight(true);
win.autoAnimation = function (){
if (liLen var callboardLiFirst = callboard.find('li').first();
callboardLiFirst.animate({
marginTop:-initHeight
}, 500, function (){
clearTimeout(callboarTimer);
callboardLiFirst.appendTo(callboardUl).css({marginTop:0});
callboarTimer(self, 5000);
callboard.mouseenter(
function (){
clearTimeout(callboarTimer);
}).mouseleave(function (){
callboarTimer = setTimeout(win.autoAnimation, 5000);
}) ;
}(ウィンドウ));
setTimeout(window.autoAnimation, 5000);
HTML代:
复制代