-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
31 lines (27 loc) · 1.06 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
document.addEventListener('DOMContentLoaded', function () {
const buttons = document.querySelectorAll('.menu-button');
const pages = document.querySelectorAll('.page');
const homePage = document.getElementById('home');
const defaultIcon = document.querySelector('[data-target="home"]');
function showPage(target) {
pages.forEach(page => {
page.style.display = 'none';
});
const targetPage = document.getElementById(target);
targetPage.style.display = 'flex';
// Manage active states
buttons.forEach(button => {
button.classList.remove('active');
});
document.querySelector(`[data-target="${target}"]`).classList.add('active');
}
buttons.forEach(button => {
button.addEventListener('click', function () {
const target = this.dataset.target;
showPage(target);
});
});
// Set default home page and icon active state on load
showPage('home');
defaultIcon.classList.add('active');
});