WordPress下拉菜单点击打开

我正在尝试创建一个单击时打开的wordpress下拉菜单。 当你选择一个post并且页面加载该post时它应该保持打开状态。 问题是我正在使用自定义菜单项链接,它链接到任何内容(“#”)只是为了使它们可以点击。 单击“可点击的第二级标题项”时菜单打开,但“第三级post”上的链接不起作用,而是单击它时菜单关闭。

HTML:

 

jQuery的:

 $('#menu-header ul.sub-menu li.second:not(".third")').toggle(function() { $(this).find('ul.sub-menu:first-of-type') .stop(true, true).delay(50).show("slow"); }, function(){ $(this).find('ul.sub-menu:first-of-type') .stop(true, true).delay(150).animate({ "height": "hide", "opacity": "hide" }, 400 ); }); 

你去,用这个答案 。 为了清晰起见,我简化了代码,并更新了你的小提琴 。

 $('ul.sub-menu').children('.second').click(function(){ $(this).children('.sub-menu').slideToggle('slow'); }).children('ul').find('.third').click(function (event) { event.stopPropagation(); console.log('hello!'); return false; });