-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevent4.html
More file actions
34 lines (31 loc) · 831 Bytes
/
event4.html
File metadata and controls
34 lines (31 loc) · 831 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title> Asynchronous js</title>
</head>
<body style="background-color: #313131; color: aliceblue;">
<h2> Asynchronous js </h2>
<button id="start">Start</button>
<button id="stop">Stop</button>
</body>
<script>
//setInterval ,clearInterval
const sayDate = function(str){
console.log(str, Date.now());
}
let stop;
document.querySelector('#start').
addEventListener('click', function(){
stop =setInterval(sayDate, 1000, "hello")
console.log("START");
})
document.querySelector('#stop').
addEventListener('click', function(){
clearInterval(stop);
stop = null;
console.log("program end");
})
</script>
</html>