WordPress disable parent menu using jquery

<script language=javascript>
  jQuery("#menu-firstmenu li:has(ul.sub-menu)").hover(function () {
     jQuery(this).children("a").click(function () {
        return false;
     });
  });
</script>



About Kapil Chugh

In love with PHP and tweaking WordPress. Hungry for Open Source and new technologies. Honest. God-fearing. Happiest when solving problems.
This entry was posted in jquery, WordPress and tagged , , . Bookmark the permalink.

7 Responses to WordPress disable parent menu using jquery

  1. Mike Reid says:

    Hi Kapil,
    Thanks so much for this, it’s a great little plugin. I was wondering if you could help me out though. I have menus that look like this

    Community –
    Ontario
    North Bay

    I installed your plugin so that “Community” would not be a link, which it did perfectly. Unfortunately it also seems to have killed the link to “Ontario” as well. I assume that it is happening because while “Ontario” is a child of “Community”, it is the parent of “North Bay”. Is there an easy tweak to the script so just the top menu links are disabled, and not the sub menu links?

    Any help would be much appreciated!

    Thanks so much

    Mike

  2. Carson says:

    Finally, a simple way to do this! Thanks.

Leave a reply to Mike Reid Cancel reply