js实现轮播很简单,无限轮播也不是很难,掌握技巧就很简单了。
$(document).ready(function(){
var x=0;
var itime;
var newshop=function(){
if (x%3==1) {
$('#shopDiv').animate({'margin-left':-1842.5},1500);
clearTimeout(itime);
itime=setTimeout(function(){newshop();x++;}, 6500);
}else if(x%3==2){
$('#shopDiv').animate({'margin-left':0},0);
clearTimeout(itime);
itime=setTimeout(function(){newshop();x++;}, 0);
}else if(x%3==0){
$('#shopDiv').animate({'margin-left':-922},1500);
clearTimeout(itime);
itime=setTimeout(function(){newshop();x++;}, 6500);
}
}
itime=setTimeout(function(){newshop();x++;}, 5000);
$('#shopDiv').mouseover(function(){
clearTimeout(itime);
})
$('#shopDiv').mouseleave(function(){
clearTimeout(itime);
itime=setTimeout(function(){newshop();x++;}, 3000);
})
})