Close Navigation in mobile

Hey,

I am using a one page navigation and have put a fixed navbar in my mobile site using a code I found from you on the forum. However, I would like the navigation to close once a user has made a selection on the page. So, for example, the user clicks ‘live’ and the page scrolls down and then the navigation closes into the fixed navbar at the top.

As it is now, the navigation stays open and blocks the actual page they are looking for. You can simply close the navigation, but I would like the experience to be a bit cleaner. Can you tell me a way to do this? I have attached an image of what it looks like now, and what I would like it to look like at the 'live section of my page, without the user having to take any additional steps.

My website is jamieharrisonmusic.com

Thanks
Jamie

Hi There,

Please add the following code under Customizer > Custom > Global Javascript:

jQuery(function($) {
	$(document).on('click touchend', '.x-navbar .mobile .x-nav li>a', function(event){
		if($.attr(this, 'href').indexOf("#") >= 0 && $('.x-btn-navbar').length > 0){
			$('.x-btn-navbar').click();
		}
	});
});

Let us know how it goes!

1 Like

You’re a genius thank you :slight_smile:

You’re welcome!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.