-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathscript.js
More file actions
46 lines (37 loc) · 1.18 KB
/
script.js
File metadata and controls
46 lines (37 loc) · 1.18 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
43
44
45
46
let circleCount = 0;
let lineCount = -1;
let circle = document.getElementsByClassName("circle");
let line = document.getElementsByClassName("line");
let next = document.getElementById("next");
let prev = document.getElementById("prev");
next.addEventListener("click", () => {
if (circleCount == 3) return;
circleCount++;
lineCount++;
let arrCircle = Array.from(circle);
let arrLine = Array.from(line);
arrCircle[circleCount].classList.add("active");
arrLine[lineCount].classList.add("active");
prev.classList.remove("disabled");
if (circleCount == 3) {
next.classList.add("disabled");
prev.classList.remove("disabled");
} else {
next.classList.remove("disabled");
}
});
prev.addEventListener("click", () => {
if (circleCount == 0) return;
let arrCircle = Array.from(circle);
let arrLine = Array.from(line);
arrCircle[circleCount].classList.remove("active");
arrLine[lineCount].classList.remove("active");
next.classList.remove("disabled");
circleCount--;
lineCount--;
if (circleCount == 0) {
prev.classList.add("disabled");
} else {
prev.classList.remove("disabled");
}
});