title: jQuery: Show and hide menu
body: <p>I have this code:</p>
  
  <pre><code>$('.skaftetopmenu-li &gt; a').click(function(e) {
     e.preventDefault();
     var subid = $(this.parentNode).attr('id');
     if (subid !="forsidemenu"){
        var str = $('#submenu-content-'+subid).html();
        if ($.trim(str) == ""){
           $('.submenu-content', this.parentNode).load('http://' + skafte.base_url + '/inc/top-menu-subs/'+subid+'_submenu.html');
        }
  
     }
  }); 
  </code></pre>
  
  <p>This disables the top links. And loads the child elements when pressed. However I can only get the child elements to show but I can't get them to dissapear when I press the toplink again or press another.</p>
  
  <hr>
  
  <p>EDIT:</p>
  
  <p>Heres af piece of the HTML of the topmenu:</p>
  
  <pre><code>&lt;div id="header-menu"&gt;
     &lt;ul id="mainmenu" style="overflow: hidden;"&gt;
        &lt;li class="skaftetopmenu-li" id="forsidemenu" &gt;
           &lt;a href="http://&lt;?php echo DOMAIN?&gt;/"&gt;Forside&lt;/a&gt;
        &lt;/li&gt;
        &lt;li class="skaftetopmenu-li" id="priser"&gt;
           &lt;a href="http://&lt;?php echo DOMAIN?&gt;/priser.php"&gt;Priser &amp;amp; Sortiment&lt;/a&gt;
           &lt;div class="submenu-content" id="submenu-content-priser"&gt;&lt;/div&gt;
        &lt;/li&gt;
    &lt;li class="skaftetopmenu-li" id="onlinebestilling"&gt;
       &lt;a href="http://&lt;?php echo DOMAIN?&gt;/bestil.php"&gt;Onlinebestilling&lt;/a&gt;
           &lt;div class="submenu-content" id="submenu-content-onlinebestilling"&gt;&lt;/div&gt;
    &lt;/li&gt;
    &lt;li class="skaftetopmenu-li" id="levering-top"&gt;
       &lt;a href="http://&lt;?php echo DOMAIN?&gt;/levering-fadoel.php"&gt;Fad&amp;oslash;l til Fest&lt;/a&gt;
       &lt;div class="submenu-content" id="submenu-content-levering"&gt;&lt;/div&gt;
    &lt;/li&gt;
     &lt;/ul&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>The above div (submenu-content-priser) loads the file /inc/top-menu-subs/priser_submenu.html, which looks like this:</p>
  
  <pre><code>&lt;ul class="submenu-item-ul"&gt;
     &lt;li class="li-content"&gt;
        &lt;div class="menucontent"&gt;
           &lt;div&gt;
              &lt;b&gt;Priser på Sodavand &amp; Vand mm.&lt;/b&gt;
              &lt;ul&gt;
                 &lt;li&gt;&lt;a href="http://skafte.dk/priser.php?moms=1"&gt;Kassevarer med moms&lt;/a&gt;&lt;/li&gt;
                 &lt;li&gt;&lt;a href="http://skafte.dk/priser.php?moms=0"&gt;Kassevarer uden moms&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
           &lt;/div&gt;
           &lt;div class="last"&gt;
              &lt;b&gt;Priser på Fadøl&lt;/b&gt;
              &lt;ul&gt;
                 &lt;li&gt;&lt;a href="http://skafte.dk/priser-fadoel.php"&gt;Fad&amp;oslash;l, leje &amp; udstyr til fest&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
           &lt;/div&gt;
        &lt;/div&gt;
     &lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>