Trying to create a responsive sidebar, i want some things to be hidden when it's closed, and show when it's opened. I trying to do it with the get, set and remove Attribute, but it doesn't work. The tags already have the hidden attribute in them.
const menu = document.querySelector(".menu");
const sidebar = document.querySelector(".sidebar");
const hidden = document.querySelectorAll(".hiddens");
menu.addEventListener("click", sidebarWidth)
function sidebarWidth(){
if(sidebar.style["width"] == "5.5vw"){
sidebar.style["width"] = "18vw";
show();
} else {
sidebar.style["width"] = "5.5vw";
hide();
}
}
function show(){
hidden.getAttribute("hidden");
hidden.removeAttribute("hidden");
}
function hide(){
hidden.setAttribute("hidden");
}
Tried using the set, get and remove attribute in the sidebarWidth function, tried creating another event just for them, tried it how it is now, none worked. What's wrong?