-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.js
More file actions
28 lines (26 loc) · 726 Bytes
/
Copy pathMain.js
File metadata and controls
28 lines (26 loc) · 726 Bytes
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
const steps = Array.from(document.querySelectorAll(" .step"));
const nextBtn = document.querySelectorAll(" .next-btn");
const prevBtn = document.querySelectorAll(" .previous-btn");
nextBtn.forEach((button) => {
button.addEventListener("click", () => {
changeStep("next");
});
});
prevBtn.forEach((button) => {
button.addEventListener("click", () => {
changeStep("prev");
});
});
function changeStep(btn) {
const active = document.querySelector(".active");
let index = steps.indexOf(active);
console.log(index);
console.log(steps);
steps[index].classList.remove("active");
if (btn === "next") {
index++;
} else if (btn === "prev") {
index--;
}
steps[index].classList.add("active");
}