简单教程
提交运行
代码编辑器:
<img id="myImage" onclick="changeImage()" src="/static/i/img3.jpg" width="100" height="180"> <script> function changeImage() { var image = document.getElementById("myImage"); if (image.src.match("img3")) { image.src = "/static/i/img2.jpg"; } else { image.src = "/static/i/img3.jpg"; } } </script>
运行结果: