<script> window.onload=function () { var di=document.getElementById("div1"); var aul=document.getElementsByTagName("ul")[0]; var ali=document.getElementsByTagName("li"); aul.innerHTML+=aul.innerHTML; aul.style.width=ali[0].offsetWidth*ali.length+"px"; var speed=2; setInterval(function(){ if(aul.offsetLeft=-aul.offsetWidth/2){ aul.style.left=0; } else if(aul.offsetLeft>0){ aul.style.left=-aul.offsetWidth/2+"px"; } aul.style.left=aul.offsetLeft+speed+"px"; }, 30); } </script></head><body><input type="button" value="向左"><input type="button" value="向右"><div id="div1"> <ul> <li><img src="image/1.JPG" alt=""></li> <li><img src="image/2.JPG" alt=""></li> <li><img src="image/3.JPG" alt=""></li> <li><img src="image/4.JPG" alt=""></li> </ul></div></body></html>
添加回答
举报
0/150
提交
取消