title: jQuery Navigation Menu with Multiple Submenu Dropdowns Closing Parent Menu Item
body: <p>I'm still just learning to use jQuery and I think my problem is a pretty easy fix for anyone that knows jQuery well. </p>
  
  <p>I have some code I'm using for a navigation menu that I think works just how I want except this: The expanded parent menu items with children get closed when its child item with yet more children (submenu within submenu) is clicked/touched.</p>
  
  <p>I do want expanded submenus to close other expanded submenus on the same level/scope. For example, I want the 'First Item+' link to close if it is expanded and a user clicks on the 'Second Item+' But, of course, what I don't want is for a child item with sub-items to close it's parent. I hope this makes sense. This is the code I'm using for the jQuery:</p>
  
  <pre><code>function initMenu() {
         $('.sub-menu').hide(); // Start with sub-menus hidden
         $('.menu-item-has-children a').click(
  
         function () {
  
             var checkElement = $(this).next();
             if ((checkElement.is('ul')) &amp;&amp; (checkElement.is(':visible'))) {
                 $('.sub-menu:visible').slideToggle(260);
             }
             if ((checkElement.is('ul')) &amp;&amp; (!checkElement.is(':visible'))) {
                 removeActiveClassFromAll();
                 $(this).addClass("active");
                 $('.sub-menu:visible').slideToggle(260);
                 checkElement.slideToggle(260);
                 return false;
             }
  
             if($(this).siblings('ul').length===0 &amp;&amp; $(this).parent().parent().attr('id')==='nav')
             {
  
                 removeActiveClassFromAll();
                 $(this).addClass("active");
                 $('.sub-menu:visible').slideToggle(260);
  
                 return false;
             }
         });
     }
  
     function removeActiveClassFromAll() {
         $('.menu-item-has-children a').each(function (index) {
             $(this).removeClass("active");
         });
     }
  
  
     $(document).ready(function () {
         initMenu();
     });
  
     $('.menu').click(function (e)
  
     {
         e.stopPropagation();
  
  
     });
  </code></pre>
  
  <p>I imagine the problem is where the code calls <code>removeActiveClassFromAll</code>.</p>
  
  <p>Your help is greatly appreciated. Thanks so much and Merry Christmas/Happy Holidays!</p>