diff --git a/scripts/navbar_menu.js b/scripts/navbar_menu.js index d65feb8b91..f9857b78a3 100644 --- a/scripts/navbar_menu.js +++ b/scripts/navbar_menu.js @@ -3,13 +3,13 @@ // Toggle a menu contents to visible and rotate the menu icon function toggleMenu(menuId) { let menu = document.getElementById(menuId); - [menu.getElementsByClassName("menu-contents")].forEach(element => { - element[0].classList.toggle("invisible"); - element[0].classList.toggle("transparent"); - }); - [menu.getElementsByClassName("menu-icon")].forEach(element => { - element[0].classList.toggle("rotate"); - }); + for (const element of menu.getElementsByClassName('menu-contents')) { + element.classList.toggle("invisible"); + element.classList.toggle("transparent"); + } + for (const element of menu.getElementsByClassName('menu-icon')) { + element.classList.toggle("rotate"); + } } // Close all dropdown menus if the user clicks outside of one