<html>
<head></head>
<body>
<div id="father" style="height:100px; overflow:hidden">//這兩個屬性是必須加上的
<div id="son1">
我是第一行<br>
我是第二行<br>
我是第三行<br>
我是第四行<br>
。。。。。<br>
我是第N行<br>
</div>
<div id="son2"></div>
</div>
</body>
</html>
<script type="text/javascript">
var scrollSpeed=40;//值越大,滾動的越慢
son2.innerHTML=son1.innerHTML;
function ScrollMarquee(){
if(son2.offsetTop-father.scrollTop<=0){
father.scrollTop-=son1.offsetHeight;
}
else{
father.scrollTop++;
}
}
var ScrollTime=setInterval(ScrollMarquee,scrollSpeed);
father.onmouseover=function(){clearInterval(ScrollingMar);};//鼠標放在上面停止滾動
father.onmouseout=function(){ScrollTime=setInterval(ScrollMarquee,scrollSpeed);};//鼠標離開,重新滾動
</script>