There is a normal menu, the button (hamburger) of which appears, at a resolution of less than 768рх . When you click the menu pops up itself, but if you increase the resolution, this menu does not disappear. Of course, you can make it through the media query display:none , but then when the resolution is less than 768рх menu appears in expanded form and is not hidden by the button.
$(document).ready(function () { //Menu button on click event $('.mobile-nav-button').on('click', function() { // Toggles a class on the menu button to transform the burger menu into a cross $( ".mobile-nav-button .mobile-nav-button__line:nth-of-type(1)" ) .toggleClass( "mobile-nav-button__line--1"); $( ".mobile-nav-button .mobile-nav-button__line:nth-of-type(2)" ) .toggleClass( "mobile-nav-button__line--2"); $( ".mobile-nav-button .mobile-nav-button__line:nth-of-type(3)" ) .toggleClass( "mobile-nav-button__line--3"); // Toggles a class that slides the menu into view on the screen $('.mobile-menu').toggleClass('mobile-menu--open'); return false; // if(($(window).width()) > 767){ // $('.mobile-menu').removeClass('mobile-menu--open'); // }; });
@media. If you break something when using it, this is a sign that you need to bring the rest of the layout to the mind using the same@media, but not to consider this way to be wrong. - Stanislav Belichenko.resize. In your code, it will look like this:$(window).resize(function(){if($(window).width() > 767) $('.mobile-menu').removeClass('mobile-menu--open')})- Diskyp