Update main.js
This commit is contained in:
parent
e8f4881356
commit
e9bf79f65c
1 changed files with 39 additions and 37 deletions
76
js/main.js
76
js/main.js
|
@ -1,42 +1,44 @@
|
|||
const navItem =document.querySelector(".nav__items");
|
||||
const openNavBtn =document.querySelector("#open__nav-btn");
|
||||
const closeNavBtn =document.querySelector("#close__nav-btn");
|
||||
|
||||
const openNav =()=>{
|
||||
navItem.style.display="flex";
|
||||
openNavBtn.style.display="none";
|
||||
closeNavBtn.style.display="inline-block";
|
||||
try {
|
||||
const navItem = document.querySelector(".nav__items");
|
||||
const openNavBtn = document.querySelector("#open__nav-btn");
|
||||
const closeNavBtn = document.querySelector("#close__nav-btn");
|
||||
const openNav = () => {
|
||||
navItem.style.display = "flex";
|
||||
openNavBtn.style.display = "none";
|
||||
closeNavBtn.style.display = "inline-block";
|
||||
};
|
||||
const closeNav = () => {
|
||||
navItem.style.display = "none";
|
||||
openNavBtn.style.display = "inline-block";
|
||||
closeNavBtn.style.display = "none";
|
||||
};
|
||||
openNavBtn.addEventListener("click", openNav);
|
||||
closeNavBtn.addEventListener("click", closeNav);
|
||||
} catch (error) {
|
||||
// console.error("Error occurred in toggle functionality:", error);
|
||||
}
|
||||
const closeNav=()=>{
|
||||
navItem.style.display="none";
|
||||
openNavBtn.style.display="inline-block";
|
||||
closeNavBtn.style.display="none";
|
||||
|
||||
}
|
||||
openNavBtn.addEventListener("click", openNav)
|
||||
closeNavBtn.addEventListener("click", closeNav)
|
||||
if (window.innerWidth <= 600)
|
||||
try {
|
||||
const sidebar = document.querySelector("aside");
|
||||
const showSidebarBtn = document.querySelector("#show__sidebar-btn");
|
||||
const hideSidebarBtn = document.querySelector("#hide__sidebar-btn");
|
||||
|
||||
const showSidebar = () => {
|
||||
sidebar.style.left = "0";
|
||||
showSidebarBtn.style.display = "none";
|
||||
hideSidebarBtn.style.display = "inline-block";
|
||||
};
|
||||
|
||||
const sidebar = document.querySelector("aside");
|
||||
const showSidebarBtn = document.querySelector("#show__sidebar-btn");
|
||||
const hideSidebarBtn = document.querySelector("#hide__sidebar-btn");
|
||||
const hideSidebar = () => {
|
||||
sidebar.style.left = "-100%";
|
||||
showSidebarBtn.style.display = "inline-block";
|
||||
hideSidebarBtn.style.display = "none";
|
||||
};
|
||||
|
||||
showSidebarBtn.addEventListener("click", showSidebar);
|
||||
hideSidebarBtn.addEventListener("click", hideSidebar);
|
||||
|
||||
const showSidebar = () => {
|
||||
|
||||
sidebar.style.left = "0";
|
||||
showSidebarBtn.style.display="none";
|
||||
hideSidebarBtn.style.display='inline-block';
|
||||
|
||||
}
|
||||
|
||||
const hideSidebar = () => {
|
||||
|
||||
sidebar.style.left = "-100%";
|
||||
showSidebarBtn.style.display="inline-block";
|
||||
hideSidebarBtn.style.display="none";
|
||||
|
||||
}
|
||||
|
||||
showSidebarBtn.addEventListener("click", showSidebar);
|
||||
hideSidebarBtn.addEventListener("click", hideSidebar);
|
||||
window.onload = showSidebar;
|
||||
} catch (error) {
|
||||
// console.error("Error occurred in sidebar functionality:", error);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue