Jquery将Wordpress子菜单转换为下拉菜单

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Jquery将Wordpress子菜单转换为下拉菜单相关的知识,希望对你有一定的参考价值。

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';
  3.  
  4. $(document).ready(function() {
  5.  
  6. //hover display for main menu items
  7. $(menuContainer+' ul.menu li').hover(
  8.  
  9. //on enter
  10. function() {
  11. selectedItem = this.id;
  12. $(menuContainer+' ul li#'+selectedItem+' ul.sub-menu').fadeIn('fast');
  13. },
  14. //on leave
  15. function() {
  16. selectedItem = this.id;
  17. $(menuContainer+' ul li#'+selectedItem+' ul.sub-menu').fadeOut('fast');
  18. }
  19. );
  20. });

以上是关于Jquery将Wordpress子菜单转换为下拉菜单的主要内容,如果未能解决你的问题,请参考以下文章

Bootstrap 下拉菜单在 wordpress 上不起作用

Jquery下拉菜单单击始终打开

使用 jQuery 提交表单下拉菜单

如何为WordPress的网站建立多级菜单

jquery 下拉菜单

将自定义 CSS 导航栏从水平转换为垂直