-
Notifications
You must be signed in to change notification settings - Fork 0
/
1.14-SetInterval.html
32 lines (32 loc) · 1.15 KB
/
1.14-SetInterval.html
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
<!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>Set Interval in JS</title>
</head>
<body id="bodyTag">
<h2>Set Interval Function in JavaScript</h2>
<div id="textArea">Time in seconds : <span id="seconds"></span></div>
<script>
function show(eName,eDept){
console.log("Employee Name : "+eName+"\nEmployee Department : "+eDept);
}
// show("Rakesh","Sales");
// show("Manish","Accounting");
// setInterval(show,2000);
// setInterval(show,4000,"Rohit","Maths"); // executes only once
let count = 0;
setInterval(function(){
count++;
document.querySelector('#seconds').innerHTML = count;
let color = `#${count}15${count}15`;
document.querySelector('#textArea').style.backgroundColor = color;
},1000);
let intId = setInterval(show,5000,"Muskan","Python");
console.log(`Interval id is : ${intId}`);
// clearInterval(intId);
</script>
</body>
</html>