在线演示: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 liLen = callboard.find('li'). length;
var initHeight = callboardLi.first().outerHeight(true);
win.autoAnimation = function(){
if(liLen <= 1) return; .callee;
var callboardLiFirst = callboard.find('li').first();
callboardLiFirst.animate({
marginTop:-initHeight
}, 500, function(){
clearTimeout(callboarTimer);
callboardLiFirst.appendTo(callboardUl).css({marginTop:0});
callboarTimer = setTimeout(self, 5000)
}
callboard.mouseenter(
function (){
clearTimeout(callboarTimer);
}).mouseleave(function (){
callboarTimer = setTimeout(win.autoAnimation, 5000);
}) ;
}(창));
setTimeout(window.autoAnimation, 5000);
HTML代码:
#callboard { 높이:24px; 줄 높이:24px; Overflow:hidden;}
#callboard ul { padding:0;}
#callboard li { padding:0;}
完整演示代码: