<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <script type="text/javascript"> function init(){ setInterval("changelunbo()",1000); } var i = 1; function changelunbo(){ i++; var imgE = document.getElementById("lunbo"); imgE.src = "img/2."+i+".jpg"; if(i == 4){ i = 0; } } </script> </head> <body onload="init()"> <img src="img/2.1.jpg"/ id="lunbo"> </body> </html>