Posted By

happynuclear on 03/03/11


javascript html jquery

Versions (?)

Who likes this?

2 people have marked this snippet as a favorite


Jquery convert Wordpress sub-menus into drop-down menus

 / Published in: jQuery


When applied to a page, this script converts any sub-menus created in the Wordpress menu editor into drop-down menus without having to specify each menu item individually. Fades in sub-menu of selected list item quickly, then fades out when leaving list item or sub-menu. See url above.

Only decided to post this because I couldn't find anything similar and was sick of working with inefficient menu creator plugins in WP.

  1. //the container wrapping the menu
  2. var menuContainer = '#mainnavigation';
  4. $(document).ready(function() {
  6. //hover display for main menu items
  7. $(menuContainer+' li').hover(
  9. //on enter
  10. function() {
  11. selectedItem =;
  12. $(menuContainer+' ul li#'+selectedItem+' ul.sub-menu').fadeIn('fast');
  13. },
  14. //on leave
  15. function() {
  16. selectedItem =;
  17. $(menuContainer+' ul li#'+selectedItem+' ul.sub-menu').fadeOut('fast');
  18. }
  19. );
  20. });

Report this snippet  

You need to login to post a comment.