-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRandomColor.html
33 lines (32 loc) · 1 KB
/
RandomColor.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Random Color</title>
<link rel="icon" type="image/x-icon" href="https://file.garden/ZXPZOz_dI1vYUjXR/IMG_2148.ico">
<style>
#heading {
text-align: center;
}
</style>
</head>
<body id="theHTML">
<h1 id="heading">Color Changing Background</h1>
<script>
let color = "#";
const characters = "0123456789abcdef";
let theCharacter;
let i = 0;
setInterval(function () {
while (i < 6) {
theCharacter = characters[Math.floor(Math.random() * 16)];
color += theCharacter;
i++;
}
document.getElementById("theHTML").style.backgroundColor = color;
color = "#";
i = 0;
}, 500);
</script>
</body>
</html>