JavaScript实现的图片循环播放
直接上干货
<html> <head> <title>Banner Cycler</title> <script> var banners = ["001.jpg","002.jpg","003.jpg"]; // 图片地址 var counter = 0; function run(){ setInterval(cycle,1000); //重复运行cycle函数,周期100ms } function cycle(){ counter++; if(counter == banners.length) counter = 0; document.getElementById("banner").src = banners[counter]; } </script> </head> <body onload = "run();"> <img id="banner" alt="banner" src="001.jpg"> </body> </html>