Advertisement
vencinachev

Lamp control v2

Apr 19th, 2021
949
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3.     <head>
  4.         <title>Hello JS</title>
  5.         <script>
  6.            var isOn = false;
  7.            function lampControl(){
  8.                if (!isOn){
  9.                    document.getElementById("lampImg").src = "pic_bulbon.gif";
  10.                    document.getElementById("lampBtn").innerHTML = "LAMP OFF";
  11.                } else {
  12.                    document.getElementById("lampImg").src = "pic_bulboff.gif";
  13.                    document.getElementById("lampBtn").innerHTML = "LAMP ON";
  14.                }
  15.                isOn = !isOn;
  16.            }
  17.         </script>
  18.     </head>
  19.     <body>
  20.         <button onclick="lampControl()" id="lampBtn"> LAMP ON </button>
  21.         <img src="pic_bulboff.gif" id="lampImg">
  22.     </body>
  23. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement