0

In the twenty-twelve theme, the following code will collapse the sub-menu ul/li on the mobile version. The problem is that it also breaks the normal version of the menu. How can I use it only when the mobile menu comes in?

jQuery(document).ready(function($){
    $('.main-navigation li ul').hide();
    $('.main-navigation li').has('ul').click(function() {
    $(this).children().toggle();
    });
});`
  • What's wrong with the native menu? Twentytwelve does this by default out of the box, why do you need jQuery? – vtacreative Apr 10 '13 at 0:29
  • maybe i was not clear in my description but twenty twelve doesn't collapse the sub-pages as this jquery does. please note, i don't mean collapse the entire menu into the menu button...i mean collapse only the voices that have sub-voices so that if you click on them they will expand and show the sub-pages... – Mark Apr 10 '13 at 7:59
  • @CL75 hi...any idea? – Mark Apr 16 '13 at 18:15
  • Do you have a visual? Or a working example from a different site? I'm not sure if I understand just what you're trying to accomplish. – vtacreative Apr 16 '13 at 22:55
  • @CL75 no i'm sorry, i only found the script...i try to explain again: the subpages must be collapsed in the parent page so that the mobile menu will be shortered. when you click on the parent page the menu expands itself and you will see the subpages link... – Mark Apr 18 '13 at 11:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.