Home > Web Front-end > JS Tutorial > How to solve the problem of conflicting scrolling codes between two images on a page_javascript skills

How to solve the problem of conflicting scrolling codes between two images on a page_javascript skills

WBOY
Release: 2016-05-16 17:46:06
Original
1458 people have browsed it

Why can't the picture flow and display after I copy the two pieces of code at the same time on the homepage?

Copy code The code is as follows:











<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>

Since these two pieces of code are exactly the same, a conflict occurs. Simply modify the code of another piece of code. The areas marked in red need to be modified.
You try:
Copy the code The code is as follows:











<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>

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template