-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfatBunnyOrange.html
More file actions
40 lines (40 loc) · 1.03 KB
/
fatBunnyOrange.html
File metadata and controls
40 lines (40 loc) · 1.03 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
<!DOCTYPE html>
<html>
<head>
<title>Dynamic Styles - Timers</title>
<style>
.on{
background: orange;
}
div{
padding: 50px;
text-align: center;
border-style: solid;
font-size: 2em;
}
</style>
</head>
<body>
<button onclick="toggle()">TOGGLE</button>
<button onclick="start()">START</button>
<button onclick="stop()">STOP</button>
<div id="target">Fat Bunny strong and beautiful</div>
<script>
function toggle(){
const element = document.getElementById('target');
element.classList.toggle('on');
}
let timer = null;
function start(){
timer = setTimeout(() => {
toggle();
console.log('hello from timer');
start();
}, 100);
}
function stop(){
clearTimeout(timer);
}
</script>
</body>
</html>