This is just a really novice question on jQuery but I'm just using it to create a simple accordion menu. The HTML ouput is like this:
<ul id="nav-sub">
<li class="sub-level-0"><a href="#">Menu Item One</a></li>
<li class="parent-here last sub-level-0"><a href="#">Menu Item Two</a>
<ul>
<li class="here sub-level-1"><a href="#">Sub Menu Item One</a></li>
<li class="last sub-level-1"><a href="#">Sub Menu Item Two</a></li>
</ul>
</li>
And the jQuery I currently have is:
$(document).ready(function() {
// Show the children of the first product on page load but leave the others hidden
$("ul#nav-sub li.parent-here ul").show();
// Then attach a visibility toggle to each of the parents
if ( $("ul#nav-sub li.sub-level-0 ul").size > 0 ) {
$("ul#nav-sub li.sub-level-0 > a").click(function(){
$(this).next().slideToggle("slow");
return false; //Prevent the browser jump to the link anchor
});
}
});
This is the closest I can get it to fully working but the only thing that doesn't work is the toggle animation. Instead of a slow transition it simply jumps right open.
What I basically want is to get the slow transition effect but ALSO to only return false (prevent the default browser action of following the link anchor) if the menu item has any children (a sub list - as shown above on Menu Item Two). I need Menu Item One to return true and go straight to that page.
Thanks