-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
85 lines (65 loc) · 2.46 KB
/
app.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//the large image
let largeImg = document.getElementById('current');
let placeName = document.getElementById('placeName');
// let img1 = document.getElementById('img1');
// let img2= document.getElementById('img2');
// let img3= document.getElementById('img3');
// let img4 = document.getElementById('img4');
// let img5 = document.getElementById('img5');
// let img6 = document.getElementById('img6');
// let img7 = document.getElementById('img7');
// let img8 = document.getElementById('img8');
// img1.addEventListener('click',function(event){
// largeImg.src = event.target.src
// placeName.innerHTML = event.target.alt
// });
// img2.addEventListener('click',function(event){
// largeImg.src = event.target.src
// placeName.innerHTML = event.target.alt
// });
// img3.addEventListener('click',function(event){
// largeImg.src = event.target.src
// placeName.innerHTML = event.target.alt
// });
// img4.addEventListener('click',function(event){
// largeImg.src = event.target.src
// placeName.innerHTML = event.target.alt
// });
// img5.addEventListener('click',function(event){
// largeImg.src = event.target.src
// placeName.innerHTML = event.target.alt
// });
// img6.addEventListener('click',function(event){
// largeImg.src = event.target.src
// placeName.innerHTML = event.target.alt
// });
// img7.addEventListener('click',function(event){
// largeImg.src = event.target.src
// placeName.innerHTML = event.target.alt
// });
// img8.addEventListener('click',function(event){
// largeImg.src = event.target.src
// placeName.innerHTML = event.target.alt
// });
//Create an array with all imags
// const allImags = [img1,img2,img3,img4,img5,img6,img7,img8];
// allImags[0].addEventListener('click',switchImg);
// allImags[1].addEventListener('click',switchImg);
// allImags[2].addEventListener('click',switchImg);
// allImags[3].addEventListener('click',switchImg);
// allImags[4].addEventListener('click',switchImg);
// allImags[5].addEventListener('click',switchImg);
// allImags[6].addEventListener('click',switchImg);
// allImags[7].addEventListener('click',switchImg);
// function switchImg(event){
// current.src = event.target.src;
// placeName.innerHTML = event.target.alt;
// }
const allImgsEasy = document.querySelectorAll('.imgs img');
for(let counter = 0;counter <=7;
counter = counter + 1){
allImgsEasy[counter].addEventListener('click',function(event){
current.src = event.target.src;
placeName.innerHTML = event.target.alt;
})
}