title: jQuery on click main menu item, if has child toggle sub menu, else open link
body: <p>I am trying to create a menu with sub items. All is well except the main items that don't have any sub items should open their own links.</p>
  
  <p>Right now the toggle works like it should but when I click the main items without any sub items, they don't do anything..</p>
  
  <p>This is the HTML:</p>
  
  <pre><code>&lt;div class="menu-primary" style="display: block;"&gt;
          &lt;ul class="v-list" id="menu-menu-1"&gt;
              &lt;li class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-8 current_page_item menu-item-23" id="menu-item-23"&gt;&lt;a href="somepath.php"&gt;Browse by Type&lt;/a&gt;&lt;/li&gt;
  
              &lt;li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-has-children menu-item-30" id="menu-item-30"&gt;
                  &lt;a&gt;aaaa&lt;/a&gt;
  
                  &lt;ul class="sub-menu"&gt;
                      &lt;li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-21" id="menu-item-21"&gt;&lt;a href="somepath.php"&gt;Browse by Author&lt;/a&gt;&lt;/li&gt;
                  &lt;/ul&gt;
              &lt;/li&gt;
  
              &lt;li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-22" id="menu-item-22"&gt;&lt;a href="somepath.php"&gt;Browse by Country&lt;/a&gt;&lt;/li&gt;
  
              &lt;li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-20" id="menu-item-20"&gt;&lt;a href="somepath.php"&gt;About&lt;/a&gt;&lt;/li&gt;
          &lt;/ul&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>This is the jquery code:</p>
  
  <pre><code>$('.menu-item').click(function(event) {
      if($(this).closest("li.menu-item").children("ul.sub-menu").length)
          {
              $('.sub-menu').slideToggle('fast');
          }
          else {
              var url = $(this).closest("li.menu-item").attr('href');
              window.open(url);
          }
          return false;
      });
  </code></pre>