Change from desktop menu to mobile menu on scroll

  DIVI, Javascript, WordPress

The following code was tested with DIVI 4.8.2 in the child theme footer on 2/6/21.

<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