-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
31 lines (28 loc) · 1011 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
31
const websiteMainDisplay = document.querySelectorAll('.main-content');
const mySidebarButton = document.querySelectorAll('.mySidebar-btn');
const sections = document.querySelectorAll('.section');
function w3_open() {
document.getElementById("mySidebar").style.display = "block";
}
function w3_close() {
document.getElementById("mySidebar").style.display = "none";
}
function mySidebarChange() {
websiteMainDisplay[0].addEventListener('click',(Event) =>{
const cls = Event.target.dataset.cls;
console.log(cls);
if (cls) {
sections.forEach((section) =>{
section.classList.remove('active');
});
for(let i=0; i < sections.length; i++){
for (let j=0; j < sections[i].classList.length; j++) {
if (sections[i].classList[j] == cls) {
sections[i].classList.add('active');
}
}
};
};
})
}
mySidebarChange();