有趣心 寻找快乐
源码示意图:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style type="text/css">
#Div{
/*居中显示*/
text-align: center;
margin-top: 177px;
}
</style>
</head>
<body>
<script>
function changeImage()
{
element=document.getElementById('myimage')
if (element.src.match("Wick"))
{
element.src="image/lamp.gif";
}
else
{
element.src="image/Wick.gif";
}
}
</script>
<div id="Div">
<img id="myimage" onclick="changeImage()" border="0" src="image/lamp.gif" width="100" height="180">
<p>点击灯泡 开/关 灯</p>
</div>
</body>
</html>