代码如下:
<script>
var speed=20;/*速度数值越大速度越慢*/
document.getElementById('www_qpsh_com2').innerHTML=document.getElementById('www_qpsh_com1').innerHTML;
/*两个层来回交替出现*/
function Marquee(){
if(document.getElementById('www_qpsh_com2').offsetWidth-document.getElementById('www_qpsh_com').scrollLeft<=0)
document.getElementById('www_qpsh_com').scrollLeft-=document.getElementById('www_qpsh_com1').offsetWidth;
else{
document.getElementById('www_qpsh_com').scrollLeft++;
}
document.getElementById('my_marquee_info').innerHTML='';
document.getElementById('my_marquee_info').innerHTML+='div.scrollTop:'+document.getElementById('www_qpsh_com').scrollLeft;
}
var MyMar=setInterval(Marquee,speed);
www_qpsh_com.onmouseover=function() {clearInterval(MyMar);}
www_qpsh_com.onmouseout=function() {MyMar=setInterval(Marquee,speed);}
</script>
演示代码:
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
js实现
循环
marquee
js