-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJS12.html
More file actions
42 lines (35 loc) · 1.35 KB
/
JS12.html
File metadata and controls
42 lines (35 loc) · 1.35 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>setinterval set time out and clear time out</title>
</head>
<body>
<div class="container">
This is container
The actual Time is <span id="time"></span>
</div>
<script>
console.log('this is tutorial 12')
// setTimeout --> Allow us to run the function once after the interval of time.
// clearTimeout --> Allow us to run the function repeatedly after the interval of time.
function greet(name, byetxt){
console.log('Hello Good Morning '+ name + byetxt);
}
// setTimeout(greet, 5000, "Harsh ", "Take care");
// timeOut=setTimeout(greet, 5000, "Harsh ", "Take care");
// console.log(timeOut);
// clearTimeout(timeOut);
// intervalID = setInterval(greet, 1000, 'harsh ','hw are you! ');
// clearInterval(intervalID);
function displayTime(time){
time = new Date();
console.log(time);
document.getElementById('time').innerHTML = time;
}
setInterval(displayTime , 1000);
// setTimeout(greet(), 2000); this will timw but directly not gaining time beacuse we do not have to write in the parenthisis form
</script>
</body>
</html>