-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
40 lines (34 loc) · 1.25 KB
/
script.js
File metadata and controls
40 lines (34 loc) · 1.25 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
const second = 1000,
minute = second * 60,
hour = minute * 60,
day = hour * 24;
let countDown = new Date("Feb 27, 2020 09:00:00").getTime(),
x = setInterval(function() {
let now = new Date().getTime(),
distance = countDown - now;
(document.getElementById("days").innerText =
Math.floor(distance / day) > 0 ? Math.floor(distance / day) : 0),
(document.getElementById("hours").innerText =
Math.floor((distance % day) / hour) > 0
? Math.floor((distance % day) / hour)
: 0),
(document.getElementById("minutes").innerText =
Math.floor((distance % hour) / minute) > 0
? Math.floor((distance % hour) / minute)
: 0),
(document.getElementById("seconds").innerText =
Math.floor((distance % minute) / second) > 0
? Math.floor((distance % minute) / second)
: 0);
//do something later when date is reached
//if (distance < 0) {
// clearInterval(x);
// 'IT'S COUNTED DOWN!;
//}
}, second);
const items = document.querySelectorAll(".accordion a");
function toggleAccordion() {
this.classList.toggle("active");
this.nextElementSibling.classList.toggle("active");
}
items.forEach(item => item.addEventListener("click", toggleAccordion));