<!DOCTYPE html>
<html meta charset="utf-8">
<head>
<title>
信息滚动
</title>
<style type="text/css">
#demo{
background-color: #ade;
height: 100px;
margin-top: 30px;
overflow: hidden;
display: block;
}
ul {
list-style: none;
display: block; /* 去掉ul标签默认的点样式 */
}
li{
display: list-item;
}
</style>
<script type="text/javascript">
var area = document.getElementById('demo');
var con1 = document.getElementById('emo1');
var con2 = document.getElementById('emo2');
var speed = 50;
area.scrollTop = 0;
con2.innerHTML = con1.innerHTML;
function scrollUp(){
if(area.scrollTop >= con1.scrollHeight) {
area.scrollTop = 0;
}else{
area.scrollTop ++;
}
}
var myScroll = setInterval("scrollUp()",speed);
area.onmouseover = function(){
clearInterval(myScroll);
}
area.onmouseout = function(){
myScroll = setInterval("scrollUp()",speed);
}
</script>
</head>
<body>
<div id="demo">
<ul id="emo1">
<li class="item1">我是第1条信息</li>
<li class="item2">我是第2条信息</li>
<li class="item3">我是第3条信息</li>
<li class="item4">我是第4条信息</li>
<li class="item5">我是第5条信息</li>
<li class="item6">我是第6条信息</li>
<li class="item7">我是第7条信息</li>
<li class="item8">我是第8条信息</li>
<li class="item9">我是第9条信息</li>
<li class="item10">我是第10条信息</li>
</ul>
<ul id="emo2"></ul>
</div>
</body>
</html>