I have written code for the mobile site so that when you click the menu item, the page body becomes fixed and cannot scroll (so that we are able to scroll through the drop down menu, without the background scrolling). However, whenever I click the menu button, the page jumps to the top of the website. I am trying to get it so that when you click the menu button, the page stays where it is, and does not jump to the top. Any help is greatly appreciated.
jQuery( function($) {
$( ".x-btn-navbar" ).on('click', function(e) {
$('body').toggleClass("noScroll");
e.preventDefault();
});
});
.noScroll {
position: fixed;
}
EDIT I have tried putting e.preventDefault();
into my jQuery but it still doesn't work. The "duplicate" page that I was linked to does not work. This has been marked as a duplicate but it is not. I am trying to get help so that I can get my website to work. Please unmark as duplicate.