$(function(){ var firstImg = $('.pic li').first().clone(); $('.pic').append(firstImg).width($('.pic li').length*$('.pic li').width()); var i = 0; var timers; autoPlay(); function autoPlay(){ timers = setInterval(function(){ i++; moveImg(i); }, 2000); } function moveImg(num){ if(i==$('.pic>li').length){ i = 1; $('.pic').css({left:0}); } if(i==-1){ i=$('.pic li').length-2; $('.pic').css({left:-($('.pic li').length-1)*1800}); } $('.pic').stop().animate({left:-i*1800},1000); // $('.dian li').hide(); $('.dian li').eq(0).show(); // 换小点的标记 if(i==($('.pic li').length-1)){ $('.dian li').eq(0).addClass('red').siblings().removeClass('red'); // $('.dian li').eq(0).show().siblings().hide(); }else{ $('.dian li').eq(i).addClass('red').siblings().removeClass('red'); // $('.biao>li').eq(i).show().siblings().hide(); } } $('.wrap').mouseover(function(){ clearInterval(timers); console.log(333) }).mouseout(function(){ autoPlay(); }); // 点击小图标 跳转到指定的页面 $('.dian li').click(function(){ i = $(this).index(); moveImg(i); }); // 导航 $(".drop-down").hover(function(){ $("this").children("ul").toggle(); }) $(".drop-down2").hover(function(){ $("this").children("ul").toggle(); }) })