<div class="codetitle"> <span><a style="CURSOR: pointer" data="17763" class="copybut" id="copybut17763" onclick="doCopy('code17763')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code17763"> <br> <br> <br> <br><meta charset="utf-8"> <br><title>无标题文档</title> <br><style> <BR>*{padding:0; margin:0;} <BR>ul{ list-style:none;} <BR>#div{ width:300px; height:100px; margin:100px auto; border:1px solid #ff0000; position:relative; overflow:hidden;} <BR>#div ul{ position:absolute; height:100px; left:0;} <BR>#div ul li{ width:300px; height:100px; line-height:100px; text-align:center; float:left} <BR></style> <br><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> <br> <br> <br><input type="button" value="左"> <br><input type="button" value="右"> <br><div id="div"> <br><ul> <br><li>1</li> <br><li>2</li> <br><li>3</li> <br><li>4</li> <br> </ul> <br> </div> <br> <br> <br> </div>