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