Collapsing a list but making the header not link if there is a child
I have the following list setup I want to toggle open and close a section. This is working with the code I have below except except when you click on the menu item that slides it links to the page. When I set the return to false then all the other links in the list stop working. I think I need to do some <If then> to determine if it is a child but I am so new I am lost. Your help will be appreciated.
- ul class="menu"
li class="menu-item"
- a herf
ul class="sub-menu"
li class="menu-item"
a href
- jQuery(document).ready(function($) {
- $('.menu > li > ul').hide();
- $(".menu > li > a").click(function(){
- // slide toggle effect
- $(this).next(".menu > li > ul").slideToggle("slow");
- return true;
- });
- });