forked from dragonworm/dragonworm.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript2.js
More file actions
21 lines (17 loc) · 671 Bytes
/
script2.js
File metadata and controls
21 lines (17 loc) · 671 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const menuToggle = document.querySelector('.menu-toggle');
const navContainer = document.querySelector('.nav-container');
const navItems = document.querySelectorAll('.nav-item');
const sections = document.querySelectorAll('.section');
menuToggle.addEventListener('click', () => {
navContainer.classList.toggle('hidden');
});
navItems.forEach(item => {
item.addEventListener('click', () => {
navContainer.classList.add('hidden');
sections.forEach(section => {
section.classList.remove('visible');
});
const target = document.getElementById(item.dataset.section);
target.classList.add('visible');
});
});