0

I currently have a one page site. On the mobile version when the menu expands and i choose an item the menu stays open while the page moves to correct anchor but it is blocked by the menu. is there a code or snippet to insert to make the menu collapse after an item is selected?

Thanks

closed as off-topic by birgire, jgraup, Sisir, bueltge, Howdy_McGee Aug 29 '16 at 13:54

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

  • What specific plugin or theme is generating your menu? The answer will depend on how its coded. – Nate Allen Aug 20 '16 at 3:01
  • @nateallen I'm using athlete theme wordpress theme – rmaddx43 Aug 20 '16 at 19:01
1

Add this jQuery to your theme:

(function($) { 
    $('.nav-menu a').on('click', function(){
        if ( $(this).data('toggle') !== 'dropdown' ) {
            $('.main-menu .close-button').click();
        }
    });
})(jQuery);

It will close the menu when a nav link is clicked.

  • Thanks so much for your help! where exactly do i add it? @nateallen – rmaddx43 Aug 24 '16 at 1:50
  • Can you please advise where to insert this? Thank you! – rmaddx43 Aug 25 '16 at 10:09
  • Here's an article that talks about adding JavaScript to WordPress the right way: code.tutsplus.com/articles/… but if that's too complicated, you could use a plugin like this: wordpress.org/plugins/custom-javascript-editor – Nate Allen Aug 25 '16 at 14:12
  • You're welcome! Thank you for accepting the answer. Let me know if you need anything else. – Nate Allen Aug 25 '16 at 17:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.