var nav = document.getElementsByTagName("nav")[0]; function ToggleNav() { showNav = nav.style.display != "" && nav.style.display != "none"; if (showNav) { nav.style.display = "none"; } else { nav.style.display = "block"; } } window.addEventListener("resize", function(){ if (window.innerWidth > 885) { nav.style.display = "block"; } else { nav.style.display = "none"; } });