-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
17 lines (14 loc) · 739 Bytes
/
index.js
File metadata and controls
17 lines (14 loc) · 739 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
const navLinks = document.querySelectorAll('.nav-link');
const sections = document.querySelectorAll('section');
navLinks.forEach(link => {
link.addEventListener('click', function(event) {
event.preventDefault();
navLinks.forEach(nav => nav.classList.remove('active'));
this.classList.add('active');
const targetSection = document.querySelector(`.${this.dataset.target}`);
sections.forEach(section => section.style.display = 'none');
targetSection.style.display = 'grid';
});
});
// Default to show the first section
document.querySelector('.section').style.display = 'grid';