-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
27 lines (24 loc) · 1.04 KB
/
script.js
File metadata and controls
27 lines (24 loc) · 1.04 KB
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
let val=true;
const toggleBtn = document.querySelector('#show-close i');
const mobNavOpt = document.querySelector('#mob-nav-opt');
const navLinks = document.querySelectorAll('#mob-nav-opt li');
const mobNavBtn = document.querySelector('#mob-nav-btn');
const source = document.querySelector('nav');
const target = document.querySelector('#center');
const sourceHeight = source.offsetHeight;
target.style.marginTop = `${sourceHeight}px`;
toggleBtn.addEventListener('click', () => {
val?toggleBtn.classList.replace('ri-menu-line','ri-close-line'):toggleBtn.classList.replace('ri-close-line','ri-menu-line');
val?mobNavOpt.style.display="flex":mobNavOpt.style.display="none";
val=!val;
});
navLinks.forEach((li)=>li.addEventListener('click', () => {
toggleBtn.classList.replace('ri-close-line','ri-menu-line');
mobNavOpt.style.display="none";
val=!val;
}));
mobNavBtn.addEventListener('click', () => {
toggleBtn.classList.replace('ri-close-line','ri-menu-line');
mobNavOpt.style.display="none";
val=!val;
});