轮播图

$(function(){

var oUl=$('#box ul');

var Len=$('#box ul li').length;

var now=0;

function next(){

now++;

if(now>=(Len-8)){

$('.next').off();

oUl.stop().animate({left:-210 * (now+4)},function(){

$('.next').on('click',next);

oUl.css({left:-840});

})

now=0;

}else{

oUl.stop().animate({left:-210 * (now+4)});

}

};

function page(){

now--;

if(now<=-4){

$('.page').off();

oUl.stop().animate({'left':-210* (now+4)},function(){

$('.page').on('click',page);

oUl.css('left',-210 * (Len-8));

});

now=Len-12;

}else{

oUl.stop().animate({'left':-210 * (now+4)});

}

};

$('.page').on('click',page);

$('.next').on('click',next);

var tid=setInterval(next,1000);

$('#box').mouseenter(function(){

clearInterval(tid);

})

$('#box').mouseleave(function(){

clearInterval(tid);

tid=setInterval(next,1000);

})

})

你可能感兴趣的:(轮播图)