jquery实现多行文字图片滚动效果示例代码
更新时间:2014年10月10日 17:28:41 投稿:whsnow
多行文字图片滚动效果的实现方法有很多,本例与大家分享的是jquery实现的具体步骤,很实用的
今儿分享一个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操作Select选择的Text和Value(获取/设置/添加/删除)
本文将详细介绍下jQuery获取/设置/添加/删除Select选择的Text和Value,感兴趣的你可以参考下本文或许对你有所帮助2013-03-03
Jquery中.bind()、.live()、.delegate()和.on()之间的区别详解
在我们日常开发中经常会使用到.bind()、.live()、.delegate()和.on(),有些同学会对这四者存在一些疑虑,所以下面这篇文章主要给大家介绍了关于Jquery中.bind()、.live()、.delegate()和.on()之间区别的相关资料,需要的朋友可以参考借鉴。2017-08-08
jQuery实现在textarea指定位置插入字符或表情的方法
这篇文章主要介绍了jQuery实现在textarea指定位置插入字符或表情的方法,实例分析了jQuery操作表单元素的技巧,非常实用,具有一定参考借鉴价值,需要的朋友可以参考下2015-03-03


最新评论