本文实例为大家分享了文字无缝滚动效果,供大家参考,具体内容如下
html
js
$(function(){
Marquee("marquee");
})
原文链接:https://www.f2er.com/js/36829.html//订单滚动
var Marquee = function(id){
var container = document.getElementById(id),original = container.getElementsByTagName("dt")[0],clone = container.getElementsByTagName("dd")[0],liLength=original.getElementsByTagName("li").length,speed = 55;
if(liLength<=8){
return
}
clone.innerHTML = original.innerHTML;
var rolling = function(){
if (container.scrollTop === clone.offsetHeight) {
container.scrollTop = 0;
}
else {
container.scrollTop++;
}
}
var timer = setInterval(rolling,speed)//设置定时器
container.onmou<a href="https://www.jb51.cc/tag/SEO/" title="SEO">SEO</a>ver = function(){
clearInterval(timer)
}//鼠标移到marquee上时,清除定时器,停止滚动
container.onmou<a href="https://www.jb51.cc/tag/SEO/" title="SEO">SEO</a>ut = function(){
timer = setInterval(rolling,speed)
}//鼠标移开时重设定时器
}