-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.js
More file actions
38 lines (28 loc) · 713 Bytes
/
code.js
File metadata and controls
38 lines (28 loc) · 713 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
32
33
34
35
36
37
38
const rndColor=function()
{
const hex='0123456789ABCDEF';
let color='#';
for(i=1;i<=6;i++)
{
color+= hex[Math.floor(Math.random()*16)];
}
return color;
}
console.log(rndColor());
let stopD;
const startBackground=function(){
function bgchange(){
document.body.style.backgroundColor=rndColor();
}
if(!stopD)
{
stopD= setInterval(bgchange,1000);
}
console.log("clicked")
};
const stoptBackground=function(){
clearInterval(stopD)
stopD=null;
};
document.querySelector('#start').addEventListener('click',startBackground);
document.querySelector('#stop').addEventListener('click',stoptBackground);