标签:style blog io ar color sp on div log
//新闻滚动 (function($) { $.fn.myScroll = function(options) { var opts = $.extend(true, {}, $.fn.myScroll.defaults, options); return this.each(function() { var $this = $(this); var $li=$this.find("li"), li_len=$li.length, li_height=$li.outerHeight(), page_li_len=Math.floor($this.height()/li_height), page=Math.ceil(li_len/page_li_len), scrollHeight=li_height*(page_li_len), li_width=$li.width(), index=0; var slideFunc=function(){ if(index>=page){index=0;}else if(index<=-1){index=page-1;} console.log(index); $this.find("ul").animate({marginTop:-index*scrollHeight}); }; $this.find(".prev").on("click",function(){ index=index-1; slideFunc(); }); $this.find(".next").on("click",function(){ index=index+1; slideFunc(); }); }); }; $.fn.myScroll.defaults = { }; })(jQuery);
标签:style blog io ar color sp on div log
原文地址:http://www.cnblogs.com/dingyuanxin/p/4120297.html