jquery 上下滚动广告

2019-12-25,,,

复制代码 代码如下:
(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();

您可能感兴趣的文章:

  • js实现的文字横向无间断滚动
  • js 上下文字滚动效果
  • JS实现单行文字不间断向上滚动的方法
  • 如何使用jquery实现文字上下滚动效果
  • Jquery数字上下滚动动态切换插件
  • 随鼠标上下滚动的jquery代码
  • jquery 实现上下滚动效果示例代码
  • jquery文字上下滚动的实现方法
  • 一个JQuery写的点击上下滚动的小例子

《jquery 上下滚动广告.doc》

下载本文的Word格式文档,以方便收藏与打印。