From a WPUniversity reader:
Hi wp university love your site,
I’m having another problem with one of my menus. This time its a vertical custom menu, I would like to know how to acomplish with a jquery script(i enqued it and it is registered through functions.php) to hide/show sub-menu items when parent item is clicked? Also i would need to target only specific parents, some will have their child collapsed all time.
Here is the menu i created: http://md-projekt.hr/stipic/otvorena-galerija/
here you can see wich childs should be open and wich closed: http://md-projekt.hr/stipic/ – sidebar OTVORENA GALERIJA. Im going to style the new menu like the list you can see there.
Any jquery suggestions?
Thanks for your answers.
Hi there, you’ll probably want to hide your .sub-menu class (which is a standard WordPress submenu class) in your css. Then with jQuery click functionality open that sub menu on click. To find out how to do onclick events with jQuery please head on to http://api.jquery.com/click/ as they have many examples of how to use jQuery specifically.
You can also find answers on stack exchange such as ( http://stackoverflow.com/questions/11904879/jquery-to-toggle-sub-menu-but-keep-sub-menu-open-if-sub-menu-page-active ) to find specific jQuery answers.
On this site we’re aiming at answering questions specific to WordPress.