-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts1.js
More file actions
64 lines (60 loc) · 3.56 KB
/
scripts1.js
File metadata and controls
64 lines (60 loc) · 3.56 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
document.addEventListener("DOMContentLoaded", function () {
const buttons = {
showDolphinButton: document.querySelectorAll("#DolphinImage"),
showGiantPandaButton: document.querySelectorAll("#GiantPandaImage"),
showAsianElephantButton: document.querySelectorAll("#AsianElephantImage"),
showWildDeerButton: document.querySelectorAll("#WildDeerImage"),
showGiraffeButton: document.querySelectorAll("#GiraffeImage"),
showZebraButton: document.querySelectorAll("#ZebraImage"),
showHorseButton: document.querySelectorAll("#HorseImage"),
showKangarooButton: document.querySelectorAll("#KangarooImage"),
showLionButton: document.querySelectorAll("#LionImage"),
showTigerButton: document.querySelectorAll("#TigerImage"),
showBearButton: document.querySelectorAll("#BearImage"),
showWolfButton: document.querySelectorAll("#WolfImage"),
showCheetahButton: document.querySelectorAll("#CheetahImage"),
showRhinocerosButton: document.querySelectorAll("#RhinocerosImage"),
showHippopotamusButton: document.querySelectorAll("#HippopotamusImage"),
showCapybaraButton: document.querySelectorAll("#CapybaraImage"),
showSlothButton: document.querySelectorAll("#SlothImage"),
showKoalaButton: document.querySelectorAll("#KoalaImage"),
showSugarGlinderButton: document.querySelectorAll("#SugarGlinderImage"),
showChimpanzeeButton: document.querySelectorAll("#ChimpanzeeImage"),
showOrangutanButton: document.querySelectorAll("#OrangutanImage"),
showGorillaButton: document.querySelectorAll("#GorillaImage"),
showTurtleButton: document.querySelectorAll("#TurtleImage"),
showPorcupineButton: document.querySelectorAll("#PorcupineImage"),
showPoisonousFrogButton: document.querySelectorAll("#PoisonousFrogImage"),
showIguanaButton: document.querySelectorAll("#IguanaImage"),
showCrocodileButton: document.querySelectorAll("#CrocodileImage"),
showPythonButton: document.querySelectorAll("#PythonImage"),
showSnakeButton: document.querySelectorAll("#SnakeImage"),
showFlamingoButton: document.querySelectorAll("#FlamingoImage"),
showOstrichButton: document.querySelectorAll("#OstrichImage"),
showPeacockButton: document.querySelectorAll("#PeacockImage"),
showSwanButton: document.querySelectorAll("#SwanImage"),
showBoldEagleButton: document.querySelectorAll("#BoldEagleImage"),
showParrotButton: document.querySelectorAll("#ParrotImage"),
showMacowButton: document.querySelectorAll("#MacowImage"),
showToucanButton: document.querySelectorAll("#ToucanImage"),
showOwlButton: document.querySelectorAll("#OwlImage"),
showKingfisherButton: document.querySelectorAll("#KingfisherImage"),
showTarantulaButton: document.querySelectorAll("#TarantulaImage")
};
const modal = document.getElementById("imageModal");
const modalImage = document.getElementById("modalImage");
const captionText = document.getElementById("caption");
const closeBtn = document.querySelector(".close");
function showImageInModal(images) {
modal.style.display = "block";
modalImage.src = images[0].src;
captionText.innerHTML = images[0].alt;
}
closeBtn.onclick = function() {
modal.style.display = "none";
};
Object.keys(buttons).forEach(buttonId => {
const button = document.getElementById(buttonId);
button.addEventListener("click", () => showImageInModal(buttons[buttonId]));
});
});