作家
登录

jquery 上下滚动广告

作者: 来源:www.28hudong.com 2013-03-30 02:33:00 阅读 我要评论

复制代码 代码如下:(function($){ $.fn.extend({ rollList:function(option){ option=$.extend({ direction:"up", step:1, time:23 },option); var step_coe,scroll_coe,score_coe; if(option.direction=="up") { step_coe=1; scroll_coe=1; score_coe=1; }else { step_coe=-1; scroll_coe=-1; score_coe=0; } return this.each(function(){ var $this=$(this); var _this=this; var itemHeight; var temp=$("<DIV> </DIV>"); $this.css("overflow","hidden").children() .appendTo(temp); $this.append(temp.clone(true)).append(temp); itemHeight=$this.children(); itemHeight=itemHeight.eq(1).offset().top-itemHeight.eq(0).offset().top; while($this.children(":last").offset().top-$this.offset().top<=$this.height()) $this.append(temp.clone(true)); var roll; this.scrollTop=itemHeight*(1-score_coe); roll=function (){ temp=setInterval(function(){ if(_this.scrollTop*scroll_coe>=itemHeight*score_coe) { _this.scrollTop=(_this.scrollTop-itemHeight)*scroll_coe; } _this.scrollTop+=option.step*step_coe; },option.time); } $this.hover(function(){ clearInterval(temp); },function(){ roll(); }); roll(); }); } }) }(jQuery)); 调用如下: 复制代码 代码如下:$(elem).rollList();

  推荐阅读

  JAVASCRIPT 点击显示 隐藏层

点击显示/隐藏层 //code from www.jb51.net a{text-decoration:none;} .tab{border:1px solid #e57243;border-top:0;margin:10px 0;text-align:left;width:200px;font-size:14px;} .th{border-top:1p>>>详细阅读


本文标题:jquery 上下滚动广告

地址:http://www.17bianji.com/kaifa2/JS/28577.html

关键词: 探索发现

乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

网友点评
自媒体专栏

评论

热度

精彩导读
栏目ID=71的表不存在(操作类型=0)