Close the hamburger menu when you click outside of container

Hi, the hamburger menu stays open if I click outside its container.
Is there a way to make it close. Since there is no way to change the burger icon with a X when open, I’d rather prefer that if someone clicks out of the mobile menu, this close automatically.
Thank you for the help!
Susanna

Hello Susanna,

First thanks for using our Sydney theme!

Unfortunately we couldn’t reproduce your issue here. Could you please share your website link with us ? So we can do a inspection and see what’s happening to send the best solution for you.

Kind Regards,

Rodrigo.

aThemes Support

Hello Rodrigo,

Here’s the link: https://www.carlacarvalhodias.com/

I just would like that in mobile view if you click out of the burger menu this should close.

Thank you.

Hello Susanna,

Thanks for the link!

Please try following the steps below:

  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)') ) {
            $( document ).on('click', function(e){
                if( !$( e.target ).closest('.mainnav').length ) {
                    $('.mainnav').removeClass('toggled');
                }
            });
        }

    })(jQuery);

We hope this helps!

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

Kind Regards,

Rodrigo.

aThemes Support

1 Like

Thanks Rodrigo. It works perfectly!
You are a great support :+1:

Best regards
Susanna

1 Like

Hello Susanna,

You are welcome!

If you are satisfied with our theme and support, would be great if you leave your comment and rating in the official WordPress Themes repository. That helps us a lot: [Sydney] Reviews | WordPress.org

Let us know if you need further help.

Kind Regards,

Rodrigo.

aThemes Support

1 Like

Already did 5 stars! You deserve it!
Thanks agains
Susanna

1 Like

Hello Susanna,

Thank you very much! :slight_smile:

Kind Regards,

Rodrigo.

aThemes Support