-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
29 lines (27 loc) · 896 Bytes
/
script.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
const navigationLinks = document.querySelectorAll('.navigation-links a');
const images = document.querySelectorAll('.image-group > img');
navigationLinks.forEach((link) => {
link.addEventListener('mouseenter', (e) => {
const targetElement = link.getAttribute('data-link');
if (targetElement) {
images.forEach((image) => {
image.style.opacity = 0;
});
const targetImage = document.querySelector(
`img[data-image=${targetElement}]`
);
if (targetImage) {
targetImage.style.opacity = 1;
}
} else {
console.warn(`No data attribute for ${link.textContent} was found`);
}
});
link.addEventListener('mouseout', () => {
images.forEach((image) => {
image.style.opacity = 0;
});
const defaultImage = document.querySelector('img[data-image="default"]');
defaultImage.style.opacity = 1;
});
});