-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
51 lines (38 loc) · 1.28 KB
/
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const viewMoreLinks = document.querySelectorAll('.view-more');
viewMoreLinks.forEach((link) => {
link.addEventListener('click', () => {
const hoodie = link.parentElement;
const moreInfo = document.querySelector('.more-info');
if (moreInfo) {
moreInfo.classList.toggle('show');
}
});
});
function displayHoodieDetails(hoodieDetails) {
// Create a modal window
const modal = document.createElement('div');
modal.className = 'modal';
// Add the hoodie images
const imagesHtml = hoodieDetails.images.map((image) => {
return `<img src="${image}" alt="${hoodieDetails.description}">`;
}).join('');
modal.innerHTML = imagesHtml;
// Add the hoodie description
const descriptionHtml = `<p>${hoodieDetails.description}</p>`;
modal.innerHTML += descriptionHtml;
// Add the modal to the page
document.body.appendChild(modal);
// Add an event listener to close the modal
modal.addEventListener('click', () => {
modal.remove();
});
}
// Add event listeners to nav links
const navLinks = document.querySelectorAll('nav a');
navLinks.forEach(link => {
link.addEventListener('click', event => {
event.preventDefault();
const href = link.getAttribute('href');
document.querySelector(href).scrollIntoView();
});
});