手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >一个jquery实现的不错的多行文字图片滚动效果
一个jquery实现的不错的多行文字图片滚动效果
摘要:今儿分享一个jquery实现多行滚动效果。我看一些论坛网站上面,公告处用的较多。代码如下//多行滚动(function($){$.fn.ex...

今儿分享一个jquery实现多行滚动效果。

我看一些论坛网站上面,公告处用的较多。

代码如下

// 多行滚动 (function($){ $.fn.extend({ Scroll:function(opt,callback){ if(!opt) var opt={}; var _this=this.eq(0).find("ul:first"); var lineH=_this.find("li:first").height(), line=opt.line?parseInt(opt.line,10):parseInt(this.height()/lineH,10), speed=opt.speed?parseInt(opt.speed,10):1000, //卷动速度,数值越大,速度越慢(毫秒) timer=opt.timer?parseInt(opt.timer,10):5000; //滚动的时间间隔(毫秒) if(line==0) line=1; var upHeight=0-line*lineH; scrollUp=function(){ _this.animate({ marginTop:upHeight },speed,function(){ for(i=1;i

实例演示

代码如下

<div id="scrollDiv"> <ul> <li>我是jquery多行滚动条一</li> <li>我是jquery多行滚动条二</li> <li>我是jquery多行滚动条三</li> <li>我是jquery多行滚动条四</li> <li>我是jquery多行滚动条五</li> <li>我是jquery多行滚动条六</li> <li>我是jquery多行滚动条七</li> <li>我是jquery多行滚动条八</li> </ul> </div>

<script type="text/javascript" src="http:/(www.jb51.net)/ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script type="text/javascript"> // 多行滚动 (function($){ $.fn.extend({ Scroll:function(opt,callback){ if(!opt) var opt={}; var _this=this.eq(0).find("ul:first"); var lineH=_this.find("li:first").height(), line=opt.line?parseInt(opt.line,10):parseInt(this.height()/lineH,10), speed=opt.speed?parseInt(opt.speed,10):1000, //卷动速度,数值越大,速度越慢(毫秒) timer=opt.timer?parseInt(opt.timer,10):5000; //滚动的时间间隔(毫秒) if(line==0) line=1; var upHeight=0-line*lineH; scrollUp=function(){ _this.animate({ marginTop:upHeight },speed,function(){ for(i=1;i<=line;i++){ _this.find("li:first").appendTo(_this); } _this.css({marginTop:0}); }); } _this.hover(function(){ clearInterval(timerID); },function(){ timerID=setInterval("scrollUp()",timer); }).mouseout(); } }) })(jQuery); $(document).ready(function(){ $("#scrollDiv").Scroll({line:4,speed:1000,timer:2000}); }); </script>

【一个jquery实现的不错的多行文字图片滚动效果】相关文章:

JS+CSS实现的拖动分页效果实例

基于jQuery实现的无刷新表格分页实例

jquery实现图片左右切换的方法

jQuery实现在列表的首行添加数据

jQuery实现的多屏图像图层切换效果实例

jQuery实现首页图片淡入淡出效果的方法

一个很简单的办法实现TD的加亮效果.

jQuery实现不断闪烁文字的方法

jquery实现用户打分评分特效

javascript实现带下拉子菜单的导航菜单效果

精品推荐
分类导航