$(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').eq(0).show(); if(i==($('.pic li').length-1)){ $('.dian li').eq(0).addClass('red').siblings().removeClass('red'); }else{ $('.dian li').eq(i).addClass('red').siblings().removeClass('red'); } } $('.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(); }) })//加载函数