Rotate your phone or change to desktop for better experience

Rotate your phone or change to desktop for better experience

10. Write JavaScript Program to show light ON/OFF Demo.

 

<!DOCTYPE html>

<html>

<body>

 

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

 

<p>Click the light bulb to turn on/off the light.</p>

 

<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>

Post a Comment

0 Comments