Jump to content

User:Aoziwe/sandbox/imageswap

From Wikipedia, the free encyclopedia

<!DOCTYPE html> <html> <body>

JavaScript Can Change Images

<img id="myImage" onclick="changeImage()" src="pic_bulboff.gif" width="100" height="180">

Click the light bulb to turn on/off the light.

<script> function changeImage() {

   var image = document.getElementById('myImage');
   if (image.src.match("bulbon")) {
       image.src = "pic_bulboff.gif";
   } else {
       image.src = "pic_bulbon.gif";
   }

} </script>

</body> </html>