-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtut50_setInterval_setTimeOut.html
More file actions
39 lines (35 loc) · 1.23 KB
/
Copy pathtut50_setInterval_setTimeOut.html
File metadata and controls
39 lines (35 loc) · 1.23 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JavaScript - Set Interval & Set TimeOut</title>
</head>
<body>
<div class="container">This is a container
Time Now is <span id="time"></span>
</div>
<script>
console.log("This is javascript");
// SetTimeout --> Allows us to run function once after the interval of time
// ClearTimeout --> Allows us to run function repeatedly after the interval of time
// function greet(name){
// console.log("Hello Good Morning " +name);
// };
// greet();
// setTimeout(greet, 5000, " Jessi");
// timeOut = setTimeout(greet, 5000, " Lisa");
// console.log(timeOut);
// clearTimeout(timeOut);
// intervalID = setInterval(greet, 1500, "Goergia");
// clearInterval(intervalID);
function displayTime(){
time = new Date();
console.log(time);
document.getElementById('time').innerHTML = time;
};
setInterval(displayTime, 2000);
</script>
</body>
</html>