<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>文档标题</title>
<script>
function MyFunction1()
{
element=document.getElementById("image1");
if (element.src.match("bulbon"))
{
element.src="http://www.w3school.com.cn/i/eg_bulboff.gif";
}
else
{
element.src="http://www.w3school.com.cn/i/eg_bulbon.gif";
}
}
</script>
</head> <body> <div class="div1"> <img id="image1" src="http://www.w3school.com.cn/i/eg_bulboff.gif" onclick="MyFunction1()"/> </div> </body> </html>