-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
45 lines (36 loc) · 846 Bytes
/
index.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
//ONCLICK IMAGE SLIDER
var index = 1
show(index)
//previous button and next
function plus(n){
show(index += n)
}
function show(n) {
var allImg = document.querySelectorAll(".img_slider")
var dots = document.querySelectorAll(".dot")
if(n > allImg.length) {
index = 1
}
if(n < 1){
index = allImg.length
}
for(var i = 0 ; i < allImg.length ; i++){
allImg[i].style.display = "none"
}
allImg[index-1].style.display = "block";
}
//AUTOMATIC IMAGE SLIDER
var idx = 0
autoShow()
function autoShow(){
var imgs = document.querySelectorAll(".img_slider")
for(var i = 0 ; i < imgs.length ; i++){
imgs[i].style.display = "none"
}
idx++;
if(idx > imgs.length){
idx = 1
}
imgs[idx - 1].style.display = "block"
setTimeout(autoShow , 3000)
}