您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

jquery 上下滚动广告_jquery

2024/5/16 17:21:32发布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=$(
);
$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.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();
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product