-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspin.html
34 lines (30 loc) · 822 Bytes
/
spin.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
33
34
<!DOCTYPE html>
<html>
<head>
<title>Spinner</title>
<script>
let senses = ["Seeing", "Hearing", "Taste", "Touch", "Smell"];
let interval;
let counter = 0;
function spin() {
let spinnerElement = document.getElementById("spinner");
interval = setInterval(function() {
spinnerElement.innerHTML = senses[counter % senses.length];
counter++;
}, 100);
// Slow down and stop
setTimeout(function() {
clearInterval(interval);
let finalChoice = senses[Math.floor(Math.random() * senses.length)];
spinnerElement.innerHTML = finalChoice;
}, 2000);
}
</script>
</head>
<body>
<div id="spinner" style="font-size: 48px;">
<!-- Spinner text will go here -->
</div>
<button onclick="spin()">Spin!</button>
</body>
</html>