lampu nyala

<!DOCTYPE html>
<html>
<body>
<script>
function changeImage()
{
element=document.getElementById('myimage')
if (element.src.match("bulbon"))
  {
  element.src="http://www.w3schools.com/htmldom/pic_bulboff.gif";
  }
else
  {
  element.src="http://www.w3schools.com/htmldom/pic_bulbon.gif";
  }
}
</script>
<img id="myimage" onclick="changeImage()" border="0" src="pic_bulboff.gif" width="100" height="180">
<p>Click to turn on/off the light</p>

</body>
</html>

hasilnya


Click to turn on/off the light