-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjava.js
More file actions
31 lines (26 loc) · 920 Bytes
/
Copy pathjava.js
File metadata and controls
31 lines (26 loc) · 920 Bytes
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
let body = document.getElementById("body")
const randomColor = function() {
const hex = '0123456789ABCDEF'
let color = '#'
for(let i = 0; i < 6; i++) {
color += hex[Math.floor(Math.random() * 16)]
}
return body.style.backgroundColor = color
}
let intervalId = null;
document.querySelector("#auto").addEventListener("click", function() {
intervalId = setInterval(() => {
document.querySelector("h1").style.color = "white";
randomColor();
}, 1500);
})
document.querySelector("#reset").addEventListener("click", function() {
document.querySelector("h1").style.color = "steelblue"
body.style.backgroundColor = "white"
clearInterval(intervalId)
})
document.querySelector("#submit").addEventListener("click", function() {
document.querySelector("h1").style.color = "white"
clearInterval(intervalId)
randomColor()
})