The menu stays open when I click the link - Mobile view

Hello

I have a new WEBSITE.

The menu does not close when I click the link. I would like that the menu closes when you click the link.

Thank you & Best regards,
BR

Hi,

Try these steps:

  1. Install and activate the TC Custom JavaScript plugin
  2. Go To Appearance > Custom JavaScript
  3. Paste the following code into the provided box
    (function($){

      'use strict'

      $('.btn-menu').on('click', function() {
        var navBlock = $('#mainnav-mobi');

        if (navBlock.is(':visible')) {
            $(window).trigger('slideMenuOpen');
        } else {
            $(window).off( 'slideMenuOpen' );
        }

      });

      $(window).on('slideMenuOpen', function() {

        $('#mainnav-mobi .menu-item a').click(function(){
          $('#mainnav-mobi').slideUp();
          $(window).off( 'slideMenuOpen' );
        });

        $('.btn-menu, #mainnav-mobi').click(function(event){
          event.stopPropagation();
        });

      });

    })(jQuery);
  1. Update

Regards,
Kharis
aThemes Support

Thank you Kharis

I tried it, but it did not work.

Thank you for your help & Best regards,
BR

The problem is there only in my mobile view.

I have a sticky menu header and this happens only for the links on the same page where the link in menu is.

Thank you for your help & Best regards,
BR

Hi,

Thank you for trying.

As checked with your website’s source code, seems likely you’re having a cache enabled. It may prevent web browser to recognize the added script for only cached pages are loaded. Thus you need to flush cache, clear web browser history and restart it, each time custom script added.

I request giving it a try and let me know your views.

Regards,
Kharis
aThemes Support

I tried to cache the site. I even loaded the Wp optimize plugin and cleaned the site, and then deactivated the plugin, but it is still the same.

Hi,

Thank you for getting back.

I think I should investigate and troubleshoot the code directly from your site. Just in case it is related to site specific issue. Thus I request sharing your website’s temporary admin login link and send it privately to me over direct message. You can generate the link with this plugin.

P.S.: Ensure the link expiry is set to 7 days and all admin rights are enabled.

Regards,
Kharis
aThemes Support

Hi there!
I have the same problem: the mobile menu stays open when I click an anchor link.

I added your jscript but it does not work.
Could you please help me?
The site link is https://ccdias.com/test01/, if you need I can make you a login.

Thank you!
Susanna

Hello @susanna70,

First thanks for using our Sydney theme!

Try these steps:

  1. Install and activate the TC Custom JavaScript plugin
  2. Go To Appearance > Custom JavaScript
  3. Paste the following code into the provided box
(function($) {
    if ( matchMedia( 'only screen and (max-width: 1024px)' ).matches ) {
        $('.menu li a').on('click', function(){
            $('#mainnav-mobi').removeClass('toggled');
        });
    }
})(jQuery);

We hope this helps!

Please try that and let us know if you need further assistance.

Kind Regards,

Rodrigo,

aThemes Support

Hi Rodrigo!

You are simply great!!!
It works perfectly. Thank you very much!

Sydney theme is very good and your support is TOP!

Best regards
Susanna

Hello Susanna,

Thank you very much and so glad to know you are enjoiyng with our theme and support!

If you need further help, feel free to contact us.

Kind Regards,

Rodrigo,
aThemes Support

Thank you Rodrigo,

This solved my (the same) problem also. Great work.

Thank you & Best regards,
BR

1 Like

Hi BR,

Great, and thanks for the kind words!

If you are satisfied with our theme and support, would be great if you leave your comment and rating in the offical WordPress Themes repository. That helps us a lot: https://wordpress.org/support/theme/sydney/reviews/#new-post

Let us know if you need further help.

Kind Regards,

Rodrigo.

aThemes Support