const toggleBtn=document.getElementById('toggle') const sidebar=document.getElementById('sidebar') function toggleSidebar(){ sidebar.classList.toggle('close') toggleBtn.classList.toggle('rotate') Array.from(sidebar.getElementsByClassName('show')).forEach(ul=>{ ul.classList.remove('show') ul.previousElementSibling.classList.remove('rotate') }) } function toggleSubMenu(button){ button.nextElementSibling.classList.toggle('show') button.classList.toggle('rotate') if(sidebar.classList.contains('close')){ sidebar.classList.toggle('close') toggleBtn.classList.toggle('rotate') } }var dropdown = document.getElementsByClassName("dropdown-btn"); var i; for (i = 0; i < dropdown.length; i++) { dropdown[i].addEventListener("click", function() { this.classList.toggle("active"); var dropdownContent = this.nextElementSibling; if (dropdownContent.style.display === "block") { dropdownContent.style.display = "none"; } else { dropdownContent.style.display = "block"; } }); } //const body = document.querySelector("body"), // sidebar=body.querySelector(".sidebar"), // toggle=body.querySelector(".toggle") //toggle.addEventListener("click",() =>{ //sidebar.classList.toggle("close"); //});