-
Notifications
You must be signed in to change notification settings - Fork 501
Expand file tree
/
Copy pathslider.js
More file actions
26 lines (19 loc) · 688 Bytes
/
slider.js
File metadata and controls
26 lines (19 loc) · 688 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
var currentindex = 1
displaySlides(currentindex); //Displaying the first slide
function setSlides(num){
displaySlides(currentindex+=num) //updating which slides to display
}
function displaySlides(num){
var x;
var slides = document.getElementsByClassName("Images");
if (num > slides.length){ //Looping back to first slide
currentindex = 1
}
if (num < 1){ //looping back to last slide
currentindex = slides.length
}
for(x =0 ; x <slides.length ; x++){ //hiding all slides
slides[x].style.display = "none";
}
slides[currentindex - 1].style.display = "block"; //making only one slide visible
}