<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <!-- <input type="button" onclick="on()" value="开灯"> --> <img id = "myImgine" border = "0" src="images/down.jpg" style=""> <!-- <input type="button" onclick="off()" value="关灯"> --> <script> function on(){ document.getElementById('myImgine').src='images/open.jpg'; } function off(){ document.getElementById('myImgine').src = 'images/down.jpg'; } var x = 0; setInterval(function(){ if(x%2==0){ on(); } else{ off(); } x++; },1000) </script> </body> </html>
标签:function,src,定时器,off,--,JavaScript,jpg From: https://www.cnblogs.com/L-1906/p/17824421.html