Heim  >  Artikel  >  Web-Frontend  >  无缝滚动js代码通俗易懂(自写)_javascript技巧

无缝滚动js代码通俗易懂(自写)_javascript技巧

WBOY
WBOYOriginal
2016-05-16 17:32:02828Durchsuche
复制代码 代码如下:





无标题文档

<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





Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn