Problems by "No scrolling page script when sidemenu is open"

I added a javascript code to stop the scrolling on the body tag, it works, but if im trying to close the sidebar, when im clicking in the body, i cant scroll the body at all. Till im refresh the side.

here is the javascript code i used:

<script>
document.addEventListener('DOMContentLoaded', () => {
 document.querySelectorAll('.menu-button').forEach(trigger => {
  trigger.addEventListener('click', function(){ 
    document.querySelectorAll('body').forEach(target => target.classList.add('no-scroll')); 
  });
 });

 document.querySelectorAll('.close-button, a, .nav-link-dropdown').forEach(trigger => {
  trigger.addEventListener('click', function(){ 
    document.querySelectorAll('body').forEach(target => target.classList.remove('no-scroll')); 
  });
 });
});
</script>

Here ist the Link of the Website: iqonic-staging.webflow.io

I hope you can help me guys:)

Greetings,
W

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