<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title></title>
</head>
<body>
```<img src="1.png.png" id="image" width="382" height="578"><br>
<input type="button" value="开关" onclick="begin()">
<div id="time" style="width: 200px;background-color: burlywood "></div>
<script>var imgs = ["2.png.png","1.png.png"];var i = 0;function begin() {document.getElementById("image").src = imgs[i];if (i==0){i=1;document.getElementById("time").innerHTML += date()+"<p>灯亮了</p><br>";}else {i=0;document.getElementById("time").innerHTML += date()+"<p>灯关了</p><br>";}}function date() {var thisDate = new Date();var str = ['日','一','二','三','四','五','六']var year = thisDate.getFullYear(); var month = thisDate.getMonth()+1; var day = thisDate.getDate(); var week = str[thisDate.getDay()]; var thistime = thisDate.toLocaleTimeString(); var day = year + "-" + month + "-" + day + "-" +"星期" +week + thistime;return day;}
</script>
</body>
</html>
这是两个图片
![在这里插入图片描述](https://img-blog.csdnimg.cn/20191013224502915.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3Nzc2N4cw==,size_16,color_FFFFFF,t_70)
![在这里插入图片描述](https://img-blog.csdnimg.cn/2019101322455678.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3Nzc2N4cw==,size_16,color_FFFFFF,t_70)