Why My Navigation Menu disappears when I resize the browser. What should I add in the Jquery to prevent this?

I have a simple Navigation Menu. I have added a media Query and the breakpoint is 400px. Everything is working perfect except one thing, whenever I expand the menu in Mobile view and then click on the Close button, everything works fine. But the problem arises when I resize the browser from mobile to PC version, whole menu disappears. What should I add in my JQuery code to prevent this Problem?

Note:
Whenever the Menu is expanded and I resize the window, it doesn’t disappear. And I am not taking care of styling the PC Version yet. I will style it later once this issue is resolved.
The Link is Below. Please have a look at it.
https://jsfiddle.net/naeemrind/3ykyLqvh/
Thanks in Advance :slight_smile:

This seems to fix it:

$(window).resize(function() {
        if ($(this).width() > 400) {
               $(".nav-menu").show(); 
        }
});
1 Like

Yeah now problem solved. Thanks :slight_smile: