/* Toggle between adding and removing the "responsive" class to topnav when the user clicks on the icon */ function toggleMenu() { var x = document.getElementById("topnav"); if (x.className === "topnav") { x.className += " responsive"; } else { x.className = "topnav"; } } /* First load all other scripts and then listen for click on menu */ document.addEventListener('turbolinks:load', () => { document.getElementById("toggleMenu").addEventListener("click", toggleMenu); });