Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <body>
- <h2>Light ON or OFF by Abhijit</h2>
- <p>Light Bulb ON or OFF using JavaScript</p>
- <button onclick="f1()">Turn on the light</button>
- <img id="img" src="2.png" style="width:300px">
- <button onclick="f2()">Turn off the light</button>
- <script>
- function f1()
- {
- var obj=document.getElementById('img');
- obj.src='1.png';
- }
- function f2()
- {
- var obj1=document.getElementById('img');
- obj1.src='2.png';
- }
- </script>
- </body>
- </html>
Add Comment
Please, Sign In to add comment