-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathBest Deals JS.js
43 lines (35 loc) · 1.09 KB
/
Best Deals JS.js
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
let i = 0;
let j = 4;
const dots = document.querySelectorAll(".dot-container button");
const images = document.querySelectorAll(".image-container img");
function next() {
document.getElementById( "content" + (i+1)).
classList.remove("active");
i = (j + i + 1) % j;
document.getElementById("content" + (i+1)).
classList.add("active");
indicator(i+1);
}
function prev() {
document.getElementById( "content" + (i+1)).
classList.remove("active");
i = (j + i - 1) % j;
document.getElementById("content" + (i+1)).
classList.add("active");
indicator(i+1);
}
function indicator(num) {
dots.forEach(function(dot) {
dot.style.backgroundColor = 'transparent';
});
document.querySelector(".dot-container button:nth-child(" + num + ")").style.backgroundColor = "#58e078"
}
function dot(index) {
images.forEach(function(image) {
image.classList.remove("active");
});
document.getElementById('content' + index).
classList.add("active");
i = index - 1;
indicator(index);
}