Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #1396400

    Hi,
    I would like to hide a burger menu item programmatically.
    Rikard ask me tu use the following CSS syntax to do it for the main menu : #menu-item-21707 { display: none! ; } and it works fine with main menu but not with burger menu. I tried several syntax but with no success (#av-burger-menu-ul #menu-item-21707).
    Many thanks for your help.
    Regards
    Jorge

    #1396406

    Hi Jorge,

    Please try to use this instead:

    #av-burger-menu-ul .menu-item-21707

    Hope it helps :)

    Best regards,
    Nikko

    #1396412

    Hi Nikki,
    Unfortunately it does not work as well. I already tried.
    Another syntax ?
    Kind regards
    Jorge

    #1396425

    Hi,
    To hide the menu item Actualité from the burger menu only on the page /toques-robes/ please try this css:

    #top.page-id-13355 #av-burger-menu-ul .menu-item-21615 {
    	display: none;
    }

    I added the page ID because your question in the original thread seemed to want to hide the menu item on the specific page, and the menu item class was different than above when I checked.
    After applying the css, please clear your browser cache and check.

    Best regards,
    Mike

    #1396503

    Hi Mike,
    Thank you for your answer. It works fine for this specific page. But the target is to hide this item menu for all pages using this menu. I’m still looking à solution. It’s weird !
    Best regards
    Jorge

    #1396510

    Hi Jorge,

    Please us this code to make it work in all pages:

    #top #av-burger-menu-ul .menu-item-21615 {
    	display: none;
    }

    If that still does not work, then you can go to Enfold > Main Menu > General (tab) > Alternate Menu For Mobile and use a different menu.

    Best regards,
    Nikko

    #1396516

    The reason for “it works fine with main menu but not with burger menu” is that main menu and burger menu are present the same time, and only visibility is changing. To avoid duplicate IDs (and to preserve html validity), the menu items in the main menu become classes with the same name. So your Menu Item in Main Menu : #menu-item-21707 will be represented in your hamburger menu as .menu-item-21707
    An ID should always be unique.

    #1396575

    Hi Guenni,
    Thank you for your explanation.
    Best regards
    Jorge

    #1396578

    Hi Nikko,
    Actually, your code works fine in all pages if I put it into the ‘Quick CCS’ box (General Styling) :
    #top #av-burger-menu-ul .menu-item-21615 {
    display: none;
    }

    The same (php) code does not work for Burger Menu (ok for main menu) using the following syntax :
    ?>
    <script>
    (function($) {
    $(“#menu-item-21615”).css(“display”, “none”);
    $(“#top #av-burger-menu-ul .menu-item-21615”).css(“display”, “none”);
    })(jQuery);
    </script>
    <?php

    What’s wrong ?
    Best regards
    Jorge

    #1396668

    Hi,
    Your script is not going to work because the mobile item is not present until the burger menu is clicked, so when the page loads and the script runs the #top #av-burger-menu-ul .menu-item-21615 is not found.
    CSS works because the rule is always available not just on page load, using the CSS solution for this simple rule is the best option but if you really want a script to do it instead try this one:

    function custom_script() { ?>
      <script>
    window.addEventListener('DOMContentLoaded', function() {
      (function($){ 
      	$('#menu-item-21615').css({'display':'none'});
        $('.avia_mobile').on('click', '.av-burger-menu-main', function() {
        $('#top #av-burger-menu-ul .menu-item-21615').css({'display':'none'});
        });
      }(jQuery));
    });
    </script>
      <?php
    }
    add_action('wp_footer', 'custom_script');

    Best regards,
    Mike

    #1397051

    Hi Mike,
    Your explanation was very helpful for my understanding. I tried your script and it works fine now. It is so great thanks to you !
    I really appreciate your support.
    Please close this thread.
    Many thanks one more time.
    Best regards
    Jorge

    #1397055

    Hi,
    Glad we were able to help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.

    Best regards,
    Mike

Viewing 12 posts - 1 through 12 (of 12 total)
  • The topic ‘Hide burger menu item’ is closed to new replies.