<!DOCTYPE html> <html> <body> <img id="deng" onclick="Kaiguan()" src="http://www.w3school.com.cn/i/eg_bulboff.gif" /> <script> function Kaiguan() { s=document.getElementById('deng'); if (s.src.match("boff")) { s.src="http://www.w3school.com.cn/i/eg_bulbon.gif"; }else{ s.src="http://www.w3school.com.cn/i/eg_bulboff.gif"; } } </script> </body> </html>