-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenu.js
More file actions
26 lines (23 loc) · 893 Bytes
/
Copy pathmenu.js
File metadata and controls
26 lines (23 loc) · 893 Bytes
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
// Mobile Menu Functionality
document.addEventListener('DOMContentLoaded', () => {
const hamburger = document.querySelector('.hamburger-menu');
const navLinks = document.querySelector('.nav-links');
hamburger.addEventListener('click', () => {
hamburger.classList.toggle('active');
navLinks.classList.toggle('active');
});
// Close menu when clicking outside
document.addEventListener('click', (event) => {
if (!event.target.closest('.main-nav')) {
hamburger.classList.remove('active');
navLinks.classList.remove('active');
}
});
// Close menu when clicking on a link
navLinks.querySelectorAll('a').forEach(link => {
link.addEventListener('click', () => {
hamburger.classList.remove('active');
navLinks.classList.remove('active');
});
});
});