x
1
2
<html>
3
<head>
4
<meta charset="utf-8">
5
</head>
6
<body>
7
<script>
8
function changeImage() {
9
element = document.getElementById('myimage')
10
if (element.src.match("bulbon")) {
11
element.src = "/images/pic_bulboff.gif";
12
} else {
13
element.src = "/images/pic_bulbon.gif";
14
}
15
}
16
</script>
17
<img id="myimage" onclick="changeImage()" border="0" src="/images/pic_bulboff.gif" width="100" height="180">
18
<p>点击灯泡 开/关 灯</p>
19
20
</body>
21
</html>