Custom code for 'no scroll' on nav menu

I have an issues when using custom code to stop the page scrolling when the nav menu is open.
The ‘no scroll’ is activated when the nav menu is open but when i close it the ‘no scroll’ is staying on until i refresh the page again? It also changes the body colour to black from white. I can’t find the issue in the code.

Any help would be amazing :slight_smile:


https://preview.webflow.com/preview/rm-lee-cellar-conversions?utm_medium=preview_link&utm_source=designer&utm_content=rm-lee-cellar-conversions&preview=987b7dfd4a4b34e49fa273f6c84203bc&workflow=preview

Your code is referencing the .close class, but it looks like you’re just using the same .menu-button element to both open and close the menu.

Updating the code to the following seemed to fix the issue on my end:

<script>
$('.menu-button').on('click', function(){
  $('body').toggleClass('no-scroll');
});
</script>

@mikeyevin awesome!! This worked thank you very much :slight_smile:

I do have another custom code problem with Webflow Tabs, can you shed some light on that as well it please?

At the bottom of the ‘About’ page i have set up my testimonials on ‘Tabs’. The custom code i have put in should allow the them to run through all 4 tab-links on a loop? It’s not working correctly and is only playing 2.

Thanks in advance :slight_smile:

Managed to find the issue, thanks anyway :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.