帮忙修改一下JS代码?这个是简单的图片无缝循环滚动代码,但是循环1次就出错了,后面不循环了? 50
<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><title>ZuiYangDan</title><sty...
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>ZuiYangDan</title> <style> * { margin: 0; padding: 0; list-style: none; } #container { width: 100%; border: 1px solid #aaa; margin: 100px 0px; } #pictures { width: 100%; height: 520px; overflow: hidden; position: relative; } #ul1 { position: absolute; left: 0; top: 0; overflow: hidden; } #ul1 li { float: left; width: 700px; height: auto; } #ul1 li img { width: 700px; height: auto; } </style> <script> window.onload = function() { var oDiv = document.getElementById("pictures"); var oUl = document.getElementById("ul1"); var speed = -3; var oLi = document.getElementsByTagName("li"); oUl.innerHTML += oUl.innerHTML;//先把图片增加一组 oUl.style.width = oLi.length * oLi[0].offsetWidth + "px"; function move() { if (oUl.offsetLeft < -oUl.offsetWidth / 2) { oUl.style.left = "0"; } oUl.style.left = oUl.offsetLeft + speed + "px"; } var timer = setInterval(move, 30); oDiv.onmouseover = function() { clearInterval(timer); }; oDiv.onmouseout = function() { timer = setInterval(move, 30); }; } </script></head><body> <div id="container"> <div id="pictures"> <ul id="ul1"> <li><img src="./image/P70225-210657.jpg" alt=""></li> <li><img src="./image/P70225-210750.jpg" alt=""></li> <li><img src="./image/P70225-210838.jpg" alt=""></li> <li><img src="./image/P70225-210909.jpg" alt=""></li> </ul> </div> </div></body></html>循环1次后,第2次后面就没有图片了?
展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询