Dashboard Temp Share Shortlinks Frames API

HTMLify

bulb.html
Views: 586 | Author: shubh
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="bulb.css">
</head>
<body>
     <div class="box">

     </div>
<button> ON </button>
<script>
    let x = document.querySelector(".box")
    let y = document.querySelector("button")
    let flag = 0;
    
    y.addEventListener("click",() =>{
        if (flag == 0){
        x.style.backgroundColor = "white";
        y.innerText = "OFF";
        console.log("clicked");
        flag = 1;
        }
        else{
       
        x.style.backgroundColor ="transparent";
        y.innerText = "ON";
        console.log("again clicked");
        flag = 0;
        }
    });
    
    
    

    
</script>
</body>
</html>