• Resolved nathanhughes57

    (@nathanhughes57)


    Hi there,

    Big fan of the plugin and saved me a bunch of time on my site, just wondered if there was a way to auto close the menu when anchor links are clicked?

    I’ve seen a couple of people having this issue and having to add custom JS in order to fix it.

    I did try this using Simple Custom CSS and JS but then realised I was using elementor’s theme builder to create a header and footer and so maybe the JS was being embedded on the theme’s (Astra) default footer and not being pulled through.

    So, although bad practise, I tried inserting the same script in under an html tag when building the footer (shown below) however this still didn’t work.

    Any further help you could give would be greatly appreaciated.

    (FYI the only current anchor linked section is “FAQ”)

    Thanks in advance

    JS used in Simple Custom CSS and JS

    ( function() {
    jQuery( document ).ready( function() {
    jQuery( “.fsmfe-wrapper” ).find( “a” ).click( function() {
    jQuery( this ).closest( “.fsmfe-wrapper” ).find( “.menu-toggle” ).prop( “checked”, false );
    } );
    } );
    }() );

    JS embedded on footer manually

    <script type=”text/javascript” src=”https://www.zig-zag.co/wp-content/uploads/custom-css-js/345.js”&gt;

    ( function() {
    jQuery( document ).ready( function() {
    jQuery( “.fsmfe-wrapper” ).find( “a” ).click( function() {
    jQuery( this ).closest( “.fsmfe-wrapper” ).find( “.menu-toggle” ).prop( “checked”, false );
    } );
    } );
    }() );

    </script>

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Solitweb

    (@solitweb)

    If you open the console in Chrome DevTools (for example) on your site you see a lot of errors.

    One of the errors is a SyntaxError in the JavaScript file you mentioned before (345.js). You have to remove the script tags (<script></script>) and other characters (like code comments) when you copy the code snipped in a .js file!

    • This reply was modified 5 years, 9 months ago by Solitweb.
    Thread Starter nathanhughes57

    (@nathanhughes57)

    Apologies for my sloppiness but thanks for your help!

    All sorted and working now.

    Hi,
    How can you apply the above code, My code still not works?

    me to !

    • This reply was modified 5 years, 8 months ago by grufus.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Anchor links and menu closing’ is closed to new replies.