Change from desktop menu to mobile menu on scroll

DIVI, Javascript, WordPress No Comments

The following code was tested with DIVI in the footer.

<script> window.onscroll = function() {changemenu()};

function changemenu() { if (document.body.scrollTop || document.documentElement.scrollTop > 50) { document.getElementById("top-menu-nav").style.display = "none"; document.getElementById("et_mobile_nav_menu").style.display = "block"; } else { document.getElementById("top-menu-nav").style.display = "block"; document.getElementById("et_mobile_nav_menu").style.display = "none"; } }

</script>

LEAVE A COMMENT

Anti-Spam Quiz: