Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

in the twenty-twelve theme, the following code will collapse the sub-menu ul/li of the mobile version...the problem is that it also brake the normal version of the menu! how can i use it only when the mobile menu comes in?

    $('.main-navigation li ul').hide();
    $('.main-navigation li').has('ul').click(function() {
share|improve this question
What's wrong with the native menu? Twentytwelve does this by default out of the box, why do you need jQuery? –  CL75 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... –  l736k Apr 10 '13 at 7:59
@CL75 hi...any idea? –  l736k 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. –  CL75 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... –  l736k Apr 18 '13 at 11:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.