为什么我在首页同时复制出二段代码后图片不能流动显示了?
<script> <BR>var speed=25 <BR>demo2.innerHTML=demo1.innerHTML <BR>function Marquee1(){ <BR>if(demo2.offsetWidth-demo.scrollLeft<=0) <BR>demo.scrollLeft-=demo1.offsetWidth <BR>else{ <BR>demo.scrollLeft++ <BR>} <BR>} <BR>var MyMar=setInterval(Marquee1,speed) <BR>demo.onmouseover=function() {clearInterval(MyMar)} <BR>demo.onmouseout=function() {MyMar=setInterval(Marquee1,speed)} <BR></script> 由于这2段代码完全相同,所以产生冲突。把另一段代码简单修改一下代码即可。红色标注的地方是需要修改的。 你试试:
复制代码 代码如下:
<script> <BR>var speed=25 <BR>gundong2.innerHTML=gundong1.innerHTML <BR>gundong.scrollLeft=gundong.scrollWidth <BR>function Marquee1(){ <BR>if(gundong.scrollLeft<=0) <BR>gundong.scrollLeft+=gundong2.offsetWidth <BR>else{ <BR>gundong.scrollLeft-- <BR>} <BR>} <BR>var MyMar1=setInterval(Marquee1, speed) <BR>gundong.onmouseover=function() {clearInterval(MyMar1)} <BR>gundong.onmouseout=function() {MyMar1=setInterval(Marquee1, speed)} <BR></script> |