-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
43 lines (31 loc) · 1.1 KB
/
index.html
File metadata and controls
43 lines (31 loc) · 1.1 KB
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
<html>
<img id="bec"
height="500"/>
<button id="btn_previous"><</button>
<button id="btn_next">></button>
</html>
<style>
#btn_previous {
color:red;
}
#btn_next {
color:green;
}
</style>
<script>
var pictures;
pictures = ['https://i.imgur.com/1AhHHDU.jpg', 'https://i.imgur.com/OhYZSsa.jpg', 'https://i.imgur.com/NZauML6.jpg', 'https://i.imgur.com/RXSmRkz.jpg', 'https://i.imgur.com/Jx6GByr.jpg', 'https://i.imgur.com/RLknkT7.jpg', 'https://i.imgur.com/hXmoYh8.jpg'];
let element_bec = document.getElementById('bec');
pictures.push(pictures[0]);
element_bec.setAttribute("src", pictures.shift());
document.getElementById('btn_next').addEventListener('click', (event) => {
let element_bec2 = document.getElementById('bec');
pictures.push(pictures[0]);
element_bec2.setAttribute("src", pictures.shift());
});
document.getElementById('btn_previous').addEventListener('click', (event) => {
let element_bec3 = document.getElementById('bec');
pictures.unshift(pictures.slice(-1)[0]);
element_bec3.setAttribute("src", pictures.pop());
});
</script>