function img_z(id1,id2,id3){ var speed=15//速度数值越大速度越慢 var AAA=$(id1); var BBB=$(id2); var CCC=$(id3); AAA.html(BBB.html()); function Marquee(){ if(AAA[0].offsetWidth-CCC[0].scrollLeft<=0) CCC[0].scrollLeft-=BBB[0].offsetWidth else{ CCC[0].scrollLeft++; } } var MyMar=setInterval(Marquee,speed); CCC.mouseover(function() {clearInterval(MyMar)}); CCC.mouseout(function() {MyMar=setInterval(Marquee,speed)}); }
Js版
var speed=14; //数字越大速度越慢 var tab=document.getElementByIdx("runot"); var tab1=document.getElementByIdx("demo1"); var tab2=document.getElementByIdx("demo2"); tab2.innerHTML=tab1.innerHTML; function Marquee(){ if(tab2.offsetWidth-tab.scrollLeft<=0) tab.scrollLeft-=tab1.offsetWidth else{ tab.scrollLeft++; } } var MyMar=setInterval(Marquee,speed); tab.οnmοuseοver=function() {clearInterval(MyMar)}; tab.οnmοuseοut=function() {MyMar=setInterval(Marquee,speed)};