Home >Web Front-end >JS Tutorial >JS picture seamless and smooth scrolling code_javascript skills

JS picture seamless and smooth scrolling code_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-05-16 16:55:471263browse

Very smooth JS image scrolling effect code, seamless loop, customizable speed, and stops when the mouse hovers. Its characteristic is that JS and image addresses are separated. In this way, you can easily and dynamically call the address of each image from the database, which is convenient for control, so it is very practical.

Copy code The code is as follows:

.org/1999/xhtml">


< title>Image scroll









< ;a href="#">




< /div>

<script> <br><!-- <BR>var speed=10; <BR>var tab=document.getElementById("demo"); <BR>var tab1=document.getElementById("demo1"); <BR>var tab2=document.getElementById("demo2"); <BR>tab2.innerHTML=tab1.innerHTML; <BR>function Marquee(){ <BR>if(tab2.offsetWidth-tab.scrollLeft<=0) <BR>tab.scrollLeft-=tab1.offsetWidth <BR>else{ <BR>tab.scrollLeft ; <BR>} <BR>} <BR>var MyMar =setInterval(Marquee,speed); <BR>tab.onmouseover=function() {clearInterval(MyMar)}; <BR>tab.onmouseout=function() {MyMar=setInterval(Marquee,speed)}; <BR>- -> <br></script>



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