Write a JavaScript code that turns the ON and OFF Light Bulb. We will define a function turnOnOff() that will change the bulb from ON to OFF and vice versa
Syntax:
<img src = "URl" onClick=turnOnOff()>
Example: In this example, we will write a code that changes the state of bulb from ON to OFF and vice-versa by clicking on the image of bulb.
HTML
<script>    function turnOnOff() {        var image=document.getElementById('Image');        if(image.src.match("ONbulb"))            image.src=        else            image.src=    }</script>Â
    <img id="Image"          onclick="turnOnOff()"          src=Â
<p>Â Â Â Â Click on the bulb to turn it ON and OFF</p> |
Output:Â
Â

… [Trackback]
[…] Find More on on that Topic: geeksforgeeks.org/turn-on-or-off-bulb-using-javascript-2/ […]
… [Trackback]
[…] Read More Info here on that Topic: geeksforgeeks.org/turn-on-or-off-bulb-using-javascript-2/ […]
… [Trackback]
[…] Info to that Topic: geeksforgeeks.org/turn-on-or-off-bulb-using-javascript-2/ […]
… [Trackback]
[…] Find More here to that Topic: geeksforgeeks.org/turn-on-or-off-bulb-using-javascript-2/ […]