-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathslide_js.js
27 lines (25 loc) · 1021 Bytes
/
slide_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
var imageCount = 1;
var total = 3;
function slide(x) {
var image = document.getElementById('image');
imageCount = imageCount + x;
if(imageCount > total){imageCount = 1;}
if(imageCount < 1){imageCount = total;}
image.src = "images/img"+ imageCount +".jpg";
clearInterval(time); // clear interval stops the set interval.
time = window.setInterval(function slideA() { // giving the value of time the same function below starts the loop
var image = document.getElementById('image');
imageCount = imageCount + 1;
if(imageCount > total){imageCount = 1;}
if(imageCount < 1){imageCount = total;}
image.src = "images/img"+ imageCount +".jpg";
},5000);
}
var time = window.setInterval(function slideA()
{ // just assign the section to the variable so you can target it.
var image = document.getElementById('image');
imageCount = imageCount + 1;
if(imageCount > total){imageCount = 1;}
if(imageCount < 1){imageCount = total;}
image.src = "images/img"+ imageCount +".jpg";
},5000);