Mobile Menu Always Expanded

Hi! I would like for our mobile menu dropdown to be expanded by default. The only answers I can find are over a year old and don’t seem to work for our site. Can you help?

Thanks,
Jen

Hello Jen,

Thanks for writing in!

To get you issue resolve, you will need to use this custom JS code. Please add this JS code in the Theme Options > Global JS (http://prntscr.com/evswzb)

(function($){
    $(window).on('load', function(){
        var W = $(document).width();

        if ( W < 980) {
            $('.x-btn-navbar').trigger('click');
        }
    });
})(jQuery);

We would love to know if this has worked for you. Thank you.

Thanks, but that did not work. The menu isn’t expanded in mobile. Is there anything else I could try?

Hey Jen,

You seem to have quite a few licenses registered on your account so I am not sure which website is in question. The solution Runel provided is for the non pro headers, if it didn’t work then you must be finding a solution for Pro headers? If that’s the case then first assign a class to your navigation element e.g mobile-btn and then replace the previous code with the following:

(function($){
    $(document).ready(function(){
        var W = $(window).width();

        if ( W < 980) {
            $('.mobile-btn.x-anchor-toggle').click();
        }
    });
})(jQuery);

If you’re using the mobile menu in desktop screens then you can use this code instead:

(function($){
    $(document).ready(function(){
         $('.mobile-btn.x-anchor-toggle').click();
    });
})(jQuery);

Please note that the code provided above serves as a guide only and is to help you in getting started so implementing it and maintaining the code will be out of our support scope and for further maintenance for new possible versions of the theme that may cause the customization to break, you will need to hire a developer.

Don’t forget to clear all caches including your browser’s cache after adding the code. Thanks!

Thank you. I am in one of my Pro licenses. This code didn’t work either. I’m thinking I may just need to set up a mobile menu with no dropdowns. That may be the easiest solution. I can put the credentials for login if you think there is a different solution.

Hi Jennifer,

It may not work if there’s an existing JS error. To avoid much back and forth and since you do havev lots of PRO licenses, can you please share which domain have this issue so we can check directly? In case you think we need credentials, please share it inside a secure note. Thank you.

Hi, Thanks for your help. I ended up making a new mobile menu to accomodate Anchor links and that has done the trick.

Glad you sorted things out,

Cheers!

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