-
Notifications
You must be signed in to change notification settings - Fork 0
/
darkmode.html
63 lines (55 loc) · 1.09 KB
/
darkmode.html
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!DOCTYPE html>
<html>
<head>
<title>darked</title>
<style>
body,
html {
height: 100%;
width: 100%;
}
#head {
background-color: transparent;
}
.cont {
display: inline-block;
}
button {
height: 30px;
width: 60px;
padding: 5px;
color: black;
font-weight: bold;
border-radius: 12px;
border-style: solid;
cursor: pointer;
}
</style>
</head>
<body>
<div id="cont">
<h1>Dark Mode Toggle</h1>
<button>OFF</button>
</div>
<script>
let flag = 0;
var back = document.querySelector("body");
var button = document.querySelector("button");
var h1 = document.querySelector("h1");
button.addEventListener("click", function () {
if (flag == 0) {
back.style.backgroundColor = "black";
h1.style.color = "white";
button.innerHTML = "ON";
flag = 1;
}
else {
back.style.backgroundColor = "white";
h1.style.color = "black";
button.innerHTML = "OFF";
flag = 0;
}
})
</script>
</body>
</html>