W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <img id="myImage" onclick="changeImage()" src="/i/eg_bulboff.gif" width="109" height="180"> <p>单击灯泡以打开/关闭灯。</p> <script> function changeImage() { var image = document.getElementById("myImage"); if (image.src.match("eg_bulbon")) { image.src = "/i/eg_bulboff.gif"; } else { image.src = "/i/eg_bulbon.gif"; } } </script> </body> </html>