title: css menu close all open menus
body: <p>I have a menu called css menu.</p>
  
  <p>When I click onto a link I want to close all popups that are open without the
  main menu.</p>
  
  <p>I have found some examples, but they are not working for me.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$('#cssmenu a').on('click', function() {
    if ($(this).find('ul').is(':visible')) {
      // Close the menus
    }
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;div id='cssmenu'&gt;
    &lt;ul&gt;
      &lt;div id='menuspace'&gt;&lt;/div&gt;
      &lt;li&gt;&lt;a href='/0/wall/' class='ajaxtrigger'&gt;&lt;span&gt;Home&lt;/span&gt;&lt;/a&gt;
      &lt;/li&gt;"
      &lt;li class='active has-sub'&gt;&lt;a href='#'&gt;&lt;span&gt;Media&lt;/span&gt;&lt;/a&gt;"
        &lt;ul&gt;
          &lt;li class=''&gt;
            &lt;a href='/0/youtube/' class='ajaxtrigger'&gt; &lt;span&gt;Youtube&lt;/span&gt;
            &lt;/a&gt;
          &lt;/li&gt;
          &lt;li class=''&gt;&lt;a href='/0/soundcloud/' class='ajaxtrigger'&gt;&lt;span&gt;Soundcloud&lt;/span&gt;&lt;/a&gt;
          &lt;/li&gt;
          &lt;li class=''&gt;&lt;a href='/0/mixcloud/' class='ajaxtrigger'&gt;&lt;span&gt;Mixcloud&lt;/span&gt;&lt;/a&gt;
          &lt;/li&gt;
          &lt;li class=''&gt;&lt;a href='/0/pictures/' class='ajaxtrigger'&gt;&lt;span&gt;Pictures&lt;/span&gt;&lt;/a&gt;
          &lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li class='active has-sub'&gt;&lt;a href='#'&gt;&lt;span&gt;About&lt;/span&gt;&lt;/a&gt;"
        &lt;ul&gt;
          &lt;li class=''&gt;&lt;a href='/0/biography/' class='ajaxtrigger'&gt;&lt;span&gt;Biography&lt;/span&gt;&lt;/a&gt;
          &lt;/li&gt;
          &lt;li class=''&gt;&lt;a href='/0/discography/' class='ajaxtrigger'&gt;&lt;span&gt;Discography&lt;/span&gt;&lt;/a&gt;
          &lt;/li&gt;
          &lt;li class=''&gt;&lt;a href='/0/agenda/' class='ajaxtrigger'&gt;&lt;span&gt;Agenda&lt;/span&gt;    &lt;/a&gt;
          &lt;/li&gt;
          &lt;li class=''&gt;&lt;a href='/0/releases/' class='ajaxtrigger'&gt;&lt;span&gt;Releases&lt;/span&gt;&lt;/a&gt;
          &lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li class='last'&gt;&lt;a href='/0/contact' class='ajaxtrigger'&gt;&lt;span&gt;Contact&lt;/span&gt;&lt;/a&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>