Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Hello JS</title>
- <script>
- var isOn = false;
- function lampControl(){
- if (!isOn){
- document.getElementById("lampImg").src = "pic_bulbon.gif";
- document.getElementById("lampBtn").innerHTML = "LAMP OFF";
- } else {
- document.getElementById("lampImg").src = "pic_bulboff.gif";
- document.getElementById("lampBtn").innerHTML = "LAMP ON";
- }
- isOn = !isOn;
- }
- </script>
- </head>
- <body>
- <button onclick="lampControl()" id="lampBtn"> LAMP ON </button>
- <img src="pic_bulboff.gif" id="lampImg">
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement