I'm using the code below to toggle an accordion menu, but each time an item in the child menu is clicked, the menu slides up without going to the actual link.
When clicking MISC in the jsfiddle above, the menu opens. But when clicking the child link, it closes right back up. It works fine when "return false;" is removed (it's there to prevent the browser from jumping to the top of the page), but with it, the sub-menu just slides up..?
jQuery(document).ready(function ($) {
jQuery('.menu ul').slideUp(0);
jQuery('.menu li.sub').click(function () {
var target = jQuery(this).children('a');
if(target.hasClass('menu-expanded')){
target.removeClass('menu-expanded');
}else{
jQuery('.menu-item > a').removeClass('menu-expanded');
target.addClass('menu-expanded');
}
jQuery(this).find('ul:first')
.slideToggle(350)
.end()
.siblings('li')
.find('ul')
.slideUp(350);
return false;
});
});