Home  >  Article  >  Web Front-end  >  Seamless scrolling js code is easy to understand (self-written)_javascript skills

Seamless scrolling js code is easy to understand (self-written)_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:32:02863browse
复制代码 代码如下:





无标题文档

<script> <br>window.onload=function(){ <br>var oDiv=document.getElementById("div"); <br>var oUl=oDiv.getElementsByTagName("ul")[0]; <br>var oLi=oUl.getElementsByTagName("li"); <br>var oInput=document.getElementsByTagName('input'); <br>oUl.innerHTML =oUl.innerHTML; <br>oUl.style.width=oLi[0].offsetWidth*oLi.length "px"; <br>var iSeep=-2; <br>var tamer=null; <br>clearInterval(tamer); <br>function starMove(){ <br>tamer=setInterval(function(){ <br>oUl.style.left=oUl.offsetLeft iSeep "px"; <br>if(-oUl.offsetLeft >= oUl.offsetWidth/2){ <br>oUl.style.left="0px"; <br>}else if(oUl.offsetLeft>0){ <br>oUl.style.left=-oUl.offsetWidth/2 "px"; <br>} <br>},30) <br>} <br>starMove(); <br>oDiv.onmouseover=function(){ <br>clearInterval(tamer); <br>} <br>oDiv.onmouseout=function(){ <br>starMove(); <br>} <br>oInput[0].onclick=function(){ <br>iSeep=-2; <br>} <br>oInput[1].onclick=function(){ <br>iSeep=2; <br>} <br>} <br></script>






  • 1

  • 2

  • 3

  • 4





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