利用JS代码实现HTML中Marquee滚动效果

/ 0评 / 1
<html>
<body>
<div id="demo">
<div id="demo1" style="padding:0px">~~~~~~~~内容填在这里咯~~~~~~~~</div>

<div id="demo2"></div>
<div>
</div></div>
<script>
var speed=50
demo2.innerHTML=demo1.innerHTML
function Marquee(){
if(demo2.offsetTop-demo.scrollTop<=0)
demo.scrollTop-=demo1.offsetHeight
else{
demo.scrollTop++
}
}
var MyMar=setInterval(Marquee,speed)
demo.onmouseover=function() {clearInterval(MyMar)}
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</script>
</body>
</html>

发表评论

邮箱地址不会被公开。 必填项已用*标注