基于Jquery的文字滚动跑马灯插件(一个页面多个滚动区)

2019-12-24,,,,

兼容各浏览器的文本行高
复制代码 代码如下:
(function($){
$.fn.extend({
RollTitle: function(opt,callback){
if(!opt) var opt={};
var _this = this;
_this.timer = null;
_this.lineH = _this.find("li:first").height();
_this.line=opt.line?parseInt(opt.line,15):parseInt(_this.height()/_this.lineH,10);
_this.speed=opt.speed?parseInt(opt.speed,10):3000, //卷动速度,数值越大,速度越慢(毫秒
_this.timespan=opt.timespan?parseInt(opt.timespan,13):5000; //滚动的时间间隔(毫秒
if(_this.line==0) this.line=1;
_this.upHeight=0-_this.line*_this.lineH;
_this.scrollUp=function(){
_this.animate({
marginTop:_this.upHeight
},_this.speed,function(){
for(i=1;i<=_this.line;i++){
_this.find("li:first").appendTo(_this);
}
_this.css({marginTop:0});
});
}
_this.hover(function(){
clearInterval(_this.timer);
},function(){
_this.timer=setInterval(function(){_this.scrollUp();},_this.timespan);
}).mouseout();
}
})
})(jQuery);

调用方法:
line:一次卷动的文本行数
speed:卷动动画的时间
timespan:间隔时间
复制代码 代码如下:
<html>
<body>
<ul id="RunTopic">
<li>文字1</li>
<li>文字2</li>
<li>文字3</li>
<li>文字4</li>
<li>文字5</li>
</ul>
</body>
<script type="text/javascript">
$(document.body).ready(function(){
$("#RunTopic").RollTitle({line:1,speed:200,timespan:1500});
});
</script>
</html>

您可能感兴趣的文章:

  • jQuery实现适用于移动端的跑马灯抽奖特效示例
  • jQuery+CSS3文字跑马灯特效的简单实现
  • 基于jquery的文字向上跑动类似跑马灯的效果
  • jquery.rotate.js实现可选抽奖次数和中奖内容的转盘抽奖代码
  • jQuery实现转动随机数抽奖效果的方法
  • jquery实现九宫格大转盘抽奖
  • jquery——九宫格大转盘抽奖实例
  • jQuery实现类似老虎机滚动抽奖效果
  • 基于jQuery实现的双11天猫拆红包抽奖效果
  • jquery转盘抽奖功能实现
  • jQuery移动端跑马灯抽奖特效升级版(抽奖概率固定)实现方法

《基于Jquery的文字滚动跑马灯插件(一个页面多个滚动区).doc》

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