Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1270388
    waterbarry
    Participant

    I’ve a one page site.

    I want the menu fixed at the top on mobile.

    The problem is that the menu doesn’t collapse when an item is clicked. So it covers the page.

    How can I get the menu to collapse when an item is clicked?

    #1270396
    Paul R
    Moderator

    Hi,

    You can add this under Custom > Javascript in the Customizer.

    
    jQuery(function($) {
    $( ".x-navbar .mobile .x-nav li a" ).on( "click", function() {
         $('.x-btn-navbar').click();
    });
    });
    

    Hope that helps.

    #1272083
    waterbarry
    Participant

    That doesn’t seem to work for mobile. It looks like it’s a tap not a click.

    #1272098
    Thai
    Moderator

    Hi There,

    Please try with this code instead:

    (function($){
    	$('.x-navbar .x-nav-wrap.mobile a').on('click touchend', function(){
    		$('.x-nav-wrap.mobile').toggleClass('in').css('height', 0);
    		$('.x-btn-navbar').toggleClass('collapsed');
    	});
    })(jQuery);

    Hope it helps 🙂

    #1272117
    waterbarry
    Participant

    That’s perfect. Thanks

    #1272122
    Thai
    Moderator

    You’re most welcome 🙂

  • <script> jQuery(function($){ $("#no-reply-1270388 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>