Mobile Anchor link not closing menu

Hi,
I have anchor links in my hamburger menu in mobile, however when I click them, they don’t close the mobile menu view, they just go to the anchored content and keep the menu view open. Can someone help with this? Appreciate it a lot, thanks!


Here is my site Read-Only: https://preview.webflow.com/preview/main-do-not-delete?utm_medium=preview_link&utm_source=dashboard&utm_content=main-do-not-delete&preview=5a0bbe91f8076cb2dbcc39e2106b96f0&mode=preview

Hi

Closing at the second click

https://www.loom.com/share/91acbb67739a48b4a9de37b52feee823

To make external anchor links close the mobile menu, add this code snippet into your custom code via the project settings:

<script>
 $('.w-nav-menu').on('click', 'a', function() {
   $('.w-nav-button').triggerHandler('tap');
 });
</script>
1 Like

Hi Alex,

Please could you explain where this code needs adding? and which parts of the code I should change as I have renamed my mobile menu classes.

Thanks,
Matt

Add the code into : Setting / Custom code / Footer code, save and publish.