-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday3.js
64 lines (50 loc) · 1.29 KB
/
day3.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
55
56
57
58
59
60
61
62
63
64
// var paragraph = document.getElementById("info");
// var inc = document.getElementById("inc");
// var dec = document.getElementById("dec");
// var size = 12;
// inc.onclick = function () {
// size++;
// paragraph.style.fontSize = size + "px";
// };
// dec.onclick = function () {
// size--;
// paragraph.style.fontSize = size + "px";
// };
var img1 = document.getElementById("img-1");
var img2 = document.getElementById("img-2");
var img3 = document.getElementById("img-3");
var prev = document.getElementById("prev");
var nxt = document.getElementById("nxt");
img1.style.display = "block";
img2.style.display = "none";
img3.style.display = "none";
var cur_img = 1;
prev.onclick = function () {
cur_img--;
if (cur_img < 1) cur_img = 3;
change_img();
};
nxt.onclick = function () {
cur_img++;
if (cur_img > 3) cur_img = 1;
change_img();
};
function change_img() {
switch (cur_img) {
case 1:
img1.style.display = "block";
img2.style.display = "none";
img3.style.display = "none";
break;
case 2:
img1.style.display = "none";
img2.style.display = "block";
img3.style.display = "none";
break;
case 3:
img1.style.display = "none";
img2.style.display = "none";
img3.style.display = "block";
break;
}
}