$(".adver").mouseover(function(){$(".arrowRight").show();$(".arrowLeft").show();}).mouseout(function(){$(".arrowRight").hide();$(".arrowLeft").hide();})$(document).ready(function(){var i =0;//轮播图片数组var images =newArray("adver01.jpg","adver02.jpg","adver03.jpg","adver04.jpg","adver05.jpg","adver06.jpg");var interval =null;//定义一个定时器//启动定时器方法functionrun(){
interval =setInterval(right,"1500");//定时的设置}//左边按钮functionleft(){if(i ==0){
i = images.length -1;$(".adver").css("background","url(images/"+ images[i]+")");$("li").eq(i).css("background","orange");//下一个 li 位置$("li").eq(i).siblings().css("background","#333333");//去掉刚刚的 li 颜色}else{
i--;$(".adver").css("background","url(images/"+ images[i]+")");$("li").eq(i).css("background","orange");//下一个 li 位置$("li").eq(i).siblings().css("background","#333333");//去掉刚刚的 li 颜色}}//右边按钮functionright(){if(images.length -1== i){
i =0;$(".adver").css("background","url(images/"+ images[i]+")");$("li").eq(i).css("background","orange");//下一个 li 位置$("li").eq(i).siblings().css("background","#333333");//去掉刚刚的 li 颜色}else{
i++;$(".adver").css("background","url(images/"+ images[i]+")");$("li").eq(i).css("background","orange");//下一个 li 位置$("li").eq(i).siblings().css("background","#333333");//去掉刚刚的 li 颜色}}//默认启动定时器run();//左按钮单击事件$(".arrowLeft").click(function(){clearTimeout(interval);//关闭定时器
window.setTimeout(run,3000);//等待3秒继续自动轮播left();//调用左边按钮方法});//右按钮单击事件$(".arrowRight").click(function(){clearTimeout(interval);//关闭定时器
window.setTimeout(run,3000);//等待3秒继续自动轮播right();//调用右边按钮方法});})