-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathE-commerce.js
55 lines (43 loc) · 1.22 KB
/
E-commerce.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
44
45
46
47
48
49
50
51
52
53
54
var slidePosition=1;
slideshow(slidePosition);
function plusSlides(n){
slideshow(slidePosition+=n);
}
function currentSlide(n){
slideshow(slidePosition=n);
}
function slideshow(n){
var i;
var slides=document.getElementsByClassName("slide-image");
var circles=document.getElementsByClassName("dots")
if(n>slides.length){
slidePosition=1;
}
if(n<1){
slidePosition=slides.length;
}
for (i=0;i<slides.length;i++){;
slides[i].style.display="none";
}
for (i=0;i<circles.length;i++){
circles[i].className=circles[i].className.replace(" enable", "");
}
slides[slidePosition-1].style.display = "block";
circles[slidePosition-1].className += " enable";
}
var slidePosition = 0;
slideshow();
function slideshow() {
window.addEventListener('load', function() {
slideshow(slidePosition);
});
var i;
var slides = document.getElementsByClassName("slide-image");
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
slidePosition++;
if (slidePosition > slides.length) {slidePosition = 1}
slides[slidePosition-1].style.display = "block";
setTimeout(slideshow, 5000); // Change image every 2 seconds
}