-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
30 lines (26 loc) · 828 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
30
//Hamburger Menu
const bar = document.getElementById('bar');
const close = document.getElementById('close');
const nav = document.getElementById('navbar');
//if anyone clicks on the bar, the bar variable is activated
if (bar) {
bar.addEventListener('click', () => {
nav.classList.add('active');
})
}
//activating the close button
if (close) {
close.addEventListener('click', () => {
nav.classList.remove('active');
})
}
//single product script
document.addEventListener("DOMContentLoaded", function() {
const smallimg = Array.from(document.getElementsByClassName("small-img"));
const MainImg = document.getElementById("MainImg");
for (let i = 0; i < smallimg.length; i++) {
smallimg[i].onclick = function() {
MainImg.src = smallimg[i].src;
};
}
});