// 1.图片滚动 (function($) { $.fn.PicRoall = function(options) { if (!this.length) { return this; } var opts = $.extend(true, {}, $.fn.PicRoall.defaults, options); this.each(function() { var $this = $(this); var wraper = $this; var prev = $this.find('.leftbtn'); var next = $this.find('.rightbtn'); var img = $this.find('ul'); var w = img.find('li').outerWidth(true); var s = opts.speel; var flag = "left"; next.click(function(){ img.animate({'margin-left':-w}/*,1500,'easeOutBounce'*/,function(){ img.find('li').eq(0).appendTo(img); img.css({'margin-left':0}); }); flag = "left"; }); prev.click(function(){ img.find('li:last').prependTo(img); img.css({'margin-left':-w}); img.animate({'margin-left':0}/*,1500,'easeOutBounce'*/); flag = "right"; }); if (opts.autoRoall == true){ ad = setInterval(function() { flag == "left" ? next.click() : prev.click()},s*1000); wraper.hover(function(){clearInterval(ad);},function(){ad = setInterval(function() {flag == "left" ? next.click() : prev.click()},s*1000);}); } }); return this; }; // default options $.fn.PicRoall.defaults = { speel:4, autoRoall:true }; })(jQuery);