There is also a slightly different approach to this problem. You can add the onclick event to your button. Then add / remove the class to your body (similar to the previous answer, but take it before considering). This is what works for me, but with a button button, I have a checkbox that checks, toggles my mobile menu.
Add this to your section:
<script> function lockScroll() { if ($('body').hasClass('lock-scroll')) { $('body').removeClass('lock-scroll'); } else { $('body').addClass('lock-scroll'); } } </script>
Then specify the class in the CSS file / section:
.lock-scroll { overflow: hidden; }
And this will be your button:
<button type="button" id="#mob-menu-btn" onclick="lockScroll();">Click me!</button>
source share