Streaming live at 10am (PST)

Disable scroll on menu open, code not working?


#1

I’m using the code here:

<script>
Webflow.push(function() {
$('.MenuOpen_Button').click(function(e) {
e.preventDefault();
	$('body').css('overflow', 'hidden');
  });

  $('.MenuClose_Button').click(function(e) {
e.preventDefault();
	$('body').css('overflow', 'auto');
  });
});
</script>

Published site: ux-global.webflow.io

Can’t really figure out why it’s not working to be honest. Any help will be greatly appreciated!


#2

Class names are case-sensitive. Inspect your published site code.


#3

@samliew in the published site code, the class name appears as “menuopen_button w-inline-block” I’ve changed them in the code to reference that and I’m still not getting anywhere with it?


#4

menuopen_button w-inline-block is two different classes. pick one.


#5

I’ve got menuopen_button w-inline-block and menuclose_button w-inline-block can’t see the other class?


#6

I meant to say, use either menuopen_button OR w-inline-block, but not both together like this $('.menuopen_button w-inline-block'), as that is not a valid jQuery selector.


#7

Cracked it, cheers mate!