首页 > 代码库 > autoRoll_UpDown()|上下滚动函数|无缝|自动
autoRoll_UpDown()|上下滚动函数|无缝|自动
<html>
<head>
<title>自动-无缝-上下滚动</title>
<script type="text/javascript" src="http://i.tq121.com.cn/j/jquery-1.8.2.js"></script>
<link type="text/css" rel="stylesheet" href="http://i.tq121.com.cn/c/core.css">
</head>
<body>
<style>
*{padding:0; margin:0;}
div{ margin:100px;height:50px;width:200px; overflow:hidden; position:relative; }
ul{ position:absolute; top:0; left:0; width:100px;}
ul li{ height:50px; width:200px; text-align:center; line-height:50px;color:#fff; cursor:pointer;}
</style>
<div>
<ul>
<li style="background:red;">11</li>
<li style="background:blue;">22</li>
</ul>
</div>
<script>
var $U = $(‘ul‘);
//autoRoll_UpDown($U); //默认滚动速度3秒
autoRoll_UpDown($U,1000); //设置滚动速度 1秒
function autoRoll_UpDown($domObj,speed){
var speed = speed || 3000; //默认速度3秒
var len = $domObj.children().length;
var chiH = $domObj.children().height();
if(len>1){
$domObj.append($domObj.html());
var pointRoll = 0;
function move(){
pointRoll++;
if(pointRoll > len){
pointRoll = 1;
$domObj.css(‘top‘,‘0px‘);
}
$domObj.animate({top:-chiH*pointRoll+"px"});
}
var time = setInterval(move,speed)
$domObj.hover(function(){
clearInterval(time);
},function(){
time = setInterval(move,speed)
})
}
}
</script>
</body>
</html>
<head>
<title>自动-无缝-上下滚动</title>
<script type="text/javascript" src="http://i.tq121.com.cn/j/jquery-1.8.2.js"></script>
<link type="text/css" rel="stylesheet" href="http://i.tq121.com.cn/c/core.css">
</head>
<body>
<style>
*{padding:0; margin:0;}
div{ margin:100px;height:50px;width:200px; overflow:hidden; position:relative; }
ul{ position:absolute; top:0; left:0; width:100px;}
ul li{ height:50px; width:200px; text-align:center; line-height:50px;color:#fff; cursor:pointer;}
</style>
<div>
<ul>
<li style="background:red;">11</li>
<li style="background:blue;">22</li>
</ul>
</div>
<script>
var $U = $(‘ul‘);
//autoRoll_UpDown($U); //默认滚动速度3秒
autoRoll_UpDown($U,1000); //设置滚动速度 1秒
function autoRoll_UpDown($domObj,speed){
var speed = speed || 3000; //默认速度3秒
var len = $domObj.children().length;
var chiH = $domObj.children().height();
if(len>1){
$domObj.append($domObj.html());
var pointRoll = 0;
function move(){
pointRoll++;
if(pointRoll > len){
pointRoll = 1;
$domObj.css(‘top‘,‘0px‘);
}
$domObj.animate({top:-chiH*pointRoll+"px"});
}
var time = setInterval(move,speed)
$domObj.hover(function(){
clearInterval(time);
},function(){
time = setInterval(move,speed)
})
}
}
</script>
</body>
</html>
autoRoll_UpDown()|上下滚动函数|无缝|自动
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。