var speed=20; //数字越大速度越慢 var taba=document.getElementById("Demohj"); var taba1=document.getElementById("Demohj1"); var taba2=document.getElementById("Demohj2"); taba2.innerHTML=taba1.innerHTML; function Marquee(){ if(taba2.offsetWidth-taba.scrollLeft<=0) taba.scrollLeft-=taba1.offsetWidth else{ taba.scrollLeft++; } } var MyMar=setInterval(Marquee,speed); taba.onmouseover=function() {clearInterval(MyMar)}; taba.onmouseout=function() {MyMar=setInterval(Marquee,speed)};