/* --- 底部轮播图 --- */ $(document).ready(function(){ var oWrap = $("#wrap"); var oUl = $("#list"); var aLi = $("#list li"); var beforeBtn = $(".before"); var nextBtn = $(".next"); var timer = null; autoPlay(); oWrap.hover(function(){ clearInterval(timer); beforeBtn.css({"display":"block"}); nextBtn.css({"display":"block"}); },function(){ autoPlay(); beforeBtn.css({"display":"none"}); nextBtn.css({"display":"none"}); }); beforeBtn.click(function(){ oUl.animate({"left": "-" + aLi.width() + 'px'}, 500, function(){ oUl.children("li:first").insertAfter(oUl.children("li:last")); oUl.css("left", 0); }); }); nextBtn.click(function(){ oUl.animate({"left": "+" + aLi.width() + 'px'}, 500, function(){ oUl.children("li:last").insertBefore(oUl.children("li:first")); oUl.css("left", 0); }); }); /*自动播放函数*/ function autoPlay(){ timer = setInterval(function() { oUl.animate({"left": "-" + aLi.width() + 'px'}, 1000, function(){ oUl.children("li:first").insertAfter(oUl.children("li:last")); oUl.css("left", 0); }); }, 3000); } });