-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimer2.html
More file actions
58 lines (42 loc) · 1.09 KB
/
timer2.html
File metadata and controls
58 lines (42 loc) · 1.09 KB
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
<!--timer functions-->
<!DOCTYPE html>
<html lang="em">
<head>
<meta charset="UTF-8">
<script>
</script>
</head>
<body>
<h1>demo on timer functions </h1>
<h1 id="dt">Date</h1>
<h1 id="t">Time</h1>
<script>
document.querySelector("#dt").innerHTML=new Date().
toLocaleDateString();
setInterval( ()=>{
document.querySelector("#t").innerHTML=new Date().
toLocaleTimeString();
},"1000");
</script>
<button id="start"> Start</button>
<button id="stop">stop color</button>
<script>
let i;
//start logic
document.querySelector("#start").onclick=function(){
i=setInterval(()=>{
document.body.style.background=`#${Math.random()*1000000|0}`;
},"50");
}
//stop logic
document.querySelector("#stop").onclick=()=>clearInterval(i);
</script>
</body>
</html>
<!--
setTimeout()
setInterval()
callback, timer, it exe task, repeatedly for every n mi.sec
var=widow.setInterval(task,"interval")
clearTimeout()
-->