这篇文章主要介绍了js实现文字列表无缝滚动效果,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
本文实例为大家分享了js文字列表无缝滚动的具体代码,供大家参考,具体内容如下
html代码:
<p id="rule">
<p class="list" id="list">
<p>用户185****0000 获得xxx优惠券</p>
<p>用户185****0000 获得xxx优惠券</p>
<p>用户185****0000 获得xxx优惠券</p>
<p>用户185****0000 获得xxx优惠券</p>
<p>用户185****0000 获得xxx优惠券</p>
<p>用户185****0000 获得xxx优惠券</p>
<p>用户185****0000 获得xxx优惠券</p>
<p>用户185****0000 获得xxx优惠券</p>
<p>用户185****0000 获得xxx优惠券</p>
<p>用户185****0000 获得xxx优惠券</p>
<p>用户185****0000 获得xxx优惠券</p>
<p>用户185****0000 获得xxx优惠券</p>
</p>
<p class="list2" id="list2"></p>
</p>
javascript代码
var speed=50;
var list=document.getelementbyid('list');
var list2=document.getelementbyid('list2');
var rule=document.getelementbyid('rule');
list2.innerhtml=list.innerhtml;
function marquee(){
if(list2.offsettop-rule.scrolltop<=0)
rule.scrolltop-=list.offsetheight;
else{
rule.scrolltop++;
}
}
var mymar=setinterval(marquee,speed);
rule.onmouseover=function() {clearinterval(mymar)}
rule.onmouseout=function() {mymar=setinterval(marquee,speed)}
以上就是js怎么实现文字列表无缝滚动?的详细内容。