I am working on a functionality where the navigation bar items will toggle hidden or shown only when the browser width is less than 768px and an element with the class "navlogo" is clicked. I have included my code below for reference.
if ($(window).width() < 768) {
$(".navlogo").click( function (){
$(".navwrapper").toggle();
});
$(".navitem").click( function (){
$(".navwrapper").hide();
});
}
I understand that this might seem like a duplicate question, but it is not. My main concern is to make this functionality work without requiring a page refresh. If Angular.js is necessary for achieving this, I would appreciate guidance on the specific code to implement, as I am open to using it to enhance user experience.
One issue I have noticed is that if I do not include the following condition:
if ($(window).width() < 768) {}
The functionality still works correctly. However, even when the website is not in mobile mode (with a max width of 768px or lower), clicking on the element with the class "navlogo" hides the "navwrapper." While this behavior is not entirely undesirable, I would also like the "navwrapper" to hide when a user clicks on an element with the class "navitem."
Thank you for your assistance!