var innerHeight = $(window).innerHeight(); $(".block").height(innerHeight - 190); //设定高度 var Timeobj, //储存定时器 setDate_val=500, //定时器轮播时间 animateDate_val=100; //列表轮播时间 var FunInt=function(){ var blockHeight=$(‘.block‘).parent().innerHeight(); if(blockHeight==0){ blockHeight=$(‘.block‘).innerHeight(); } var blockChildren_Number=$(‘.block‘).children().length; var blockChildren_Height=$(‘.block‘).children(‘li‘).eq(0).innerHeight(); blockHeight=parseInt(blockHeight/blockChildren_Height)*blockChildren_Height; //基于LI高度的倍数高度 if(blockHeight<(blockChildren_Number*blockChildren_Height)){ $(‘.block‘).height(10000).parent().height(blockHeight).css({overflow:‘hidden‘}); var marginTop=parseInt($(‘.block‘).css(‘margin-top‘)); var nuberVal=(blockChildren_Number*blockChildren_Height)-blockHeight; nuberVal=-nuberVal; if(marginTop<0){ var kl_li_obj=$(‘.block‘).children().eq(0).clone(true); $(‘.block‘).children().eq(0).remove(); $(‘.block‘).append(kl_li_obj); $(‘.block‘).css({marginTop: marginTop+blockChildren_Height}, animateDate_val); }else{ $(‘.block‘).animate({marginTop: marginTop-blockChildren_Height}, animateDate_val); } } }; Timeobj=setInterval(FunInt,setDate_val); $(".block li").mouseenter(function(event) { clearInterval(Timeobj); }); $(".block").mouseleave(function(event) { Timeobj=setInterval(FunInt,setDate_val); });