编程宝库 - 技术改变世界
编程宝库
编程宝库提供了 JS 在线测试工具,可在线测试 JavaScript 代码,你可以在代码编辑器中输入 JavaScript 代码并点击运行查看结果。
源代码
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> <body> <script> function changeImage() { element=document.getElementById('myimage') if (element.src.match("bulbon")) { element.src="http://static.codebaoku.com/pics/24/6c/246c4653d39fdedbb8ae010ec17668ce.gif"; } else { element.src="http://static.codebaoku.com/pics/d7/c5/d7c54d33a9ab4f96492feb1ab70636ba.gif"; } } </script> <img id="myimage" onclick="changeImage()" border="0" src="http://static.codebaoku.com/pics/24/6c/246c4653d39fdedbb8ae010ec17668ce.gif" width="100" height="180"> <p>点击灯泡 开/关 灯</p> </body> </html>
运行结果