function toggleMenu() { console.log('hello'); var menuBox = document.getElementById('dropdown-content-mobile'); if(dropdown-content-mobile.style.display == "block") { // if is menuBox displayed, hide it dropdown-content-mobile.style.display = "none"; } else { // if is menuBox hidden, display it dropdown-content-mobile.style.display = "block"; } }
I would check out that if statement. instead of using your declared variable menuBox, you are using an undefined variable dropdown-content-mobile which appears to be a css ID.