title: bootstrap 4.1 navbar-collapse nav-second-level and nav-third-level
body: <p>How can I use navbar to auto-collapse all menus when I click in a specific menu item?</p>
  
  <p>For example, look at this site:
  <a href="https://blackrockdigital.github.io/startbootstrap-sb-admin-2/pages/index.html" rel="nofollow noreferrer">https://blackrockdigital.github.io/startbootstrap-sb-admin-2/pages/index.html</a></p>
  
  <p>When I click in the "UI Elements" and expand this menu, and then I click in another "Multi-Level dropdown" menu to expand it, the "UI Elements" menu close at the same time.</p>
  
  <p>I'm using a navbar menu from a bootstrap theme, AppStack, but it doesn't have this functionality. </p>
  
  <p>Bellow is my code example. I would like to click on GDTA on, if GTMAR is opened, close it. And do the same when I click ok </p>
  
  <pre><code>    &lt;nav class="sidebar"&gt;
          &lt;div class="sidebar-content "&gt;
              &lt;a class="sidebar-brand" href="index.html"&gt;
                &lt;img src="img/user.png" alt="Spider" class="align-middle img-fluid rounded-circle" width="32" height="32" /&gt;
                &lt;span class="align-middle ml-2" style="font-size:32px;"&gt;Spider&lt;/span&gt;
              &lt;/a&gt;
  
              &lt;ul class="sidebar-nav"&gt;
                  &lt;li class="sidebar-header"&gt;
                      Bases
                  &lt;/li&gt;
                  &lt;li class="sidebar-item"&gt;
                      &lt;a href="#dashboards" data-toggle="collapse" class="sidebar-link collapsed"&gt;
                        &lt;!-- &lt;i class="align-middle" data-feather="layers"&gt;&lt;/i&gt;  map layers home briefcase--&gt;
                        &lt;i class="fas fa-ship"&gt;&lt;/i&gt;&lt;span class="align-middle"&gt;GTMAR&lt;/span&gt;
                        &lt;!-- coloca Pills   &lt;span class="sidebar-badge badge badge-secondary"&gt;12/24&lt;/span&gt;   --&gt;
                      &lt;/a&gt;
                      &lt;ul id="dashboards" class="sidebar-dropdown list-unstyled collapse"&gt;
                          &lt;li class="sidebar-item"&gt;&lt;a class="sidebar-link" href="index.html"&gt;Casos&lt;/a&gt;&lt;/li&gt;
                          &lt;li class="sidebar-item"&gt;&lt;a class="sidebar-link" href="dashboard-analytics.html"&gt;Pessoas&lt;/a&gt;&lt;/li&gt;
                          &lt;li class="sidebar-item"&gt;&lt;a class="sidebar-link" href="dashboard-e-commerce.html"&gt;Ocorrências&lt;/a&gt;&lt;/li&gt;
                          &lt;li class="sidebar-item"&gt;&lt;a class="sidebar-link" href="dashboard-social.html"&gt;Organizações&lt;/a&gt;&lt;/li&gt;
                          &lt;li class="sidebar-item"&gt;&lt;a class="sidebar-link" href="dashboard-crypto.html"&gt;Aeronave &lt;span class="sidebar-badge badge badge-primary"&gt;Novo&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
                      &lt;/ul&gt;
                  &lt;/li&gt;
                  &lt;li class="sidebar-item"&gt;
                      &lt;a href="#layouts" data-toggle="collapse" class="sidebar-link collapsed"&gt;
                        &lt;!--&lt;i class="align-middle" data-feather="monitor"&gt;&lt;/i&gt;  --&gt;
                        &lt;i class="fas fa-plane"&gt;&lt;/i&gt;&lt;span class="align-middle"&gt;GDTA&lt;/span&gt;
                      &lt;/a&gt;
                      &lt;ul id="layouts" class="sidebar-dropdown list-unstyled collapse show"&gt;
                          &lt;li class="sidebar-item"&gt;
                              &lt;a href="#entidades" data-toggle="collapse" class="sidebar-link collapsed"&gt;
                                  &lt;i class="fas fa-project-diagram"&gt;&lt;/i&gt;Entidades&lt;/a&gt;
                              &lt;ul id="entidades" class="sidebar-dropdown list-unstyled collapse "&gt;
                                  &lt;li class="sidebar-item"&gt;&lt;a class="sidebar-link" href="index.html"&gt;Casos&lt;/a&gt;&lt;/li&gt;
                                  &lt;li class="sidebar-item"&gt;&lt;a class="sidebar-link" href="dashboard-analytics.html"&gt;Pessoas&lt;/a&gt;&lt;/li&gt;
                                  &lt;li class="sidebar-item"&gt;&lt;a class="sidebar-link" href="dashboard-e-commerce.html"&gt;Ocorrências&lt;/a&gt;&lt;/li&gt;
                                  &lt;li class="sidebar-item"&gt;&lt;a class="sidebar-link" href="dashboard-social.html"&gt;Organizações&lt;/a&gt;&lt;/li&gt;
                                  &lt;li class="sidebar-item"&gt;&lt;a class="sidebar-link" href="dashboard-crypto.html"&gt;Aeronave &lt;span class="sidebar-badge badge badge-danger"&gt;Atenção&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
                              &lt;/ul&gt;                                
                          &lt;/li&gt;
                          &lt;li class="sidebar-item"&gt;
                              &lt;a href="#documentos" data-toggle="collapse" class="sidebar-link collapsed"&gt;
                                  &lt;i class="fa fa-fw fa-file-alt"&gt;&lt;/i&gt;Documentos&lt;span class="sidebar-badge badge badge-secondary"&gt;12/24&lt;/span&gt;&lt;/a&gt;
                              &lt;ul id="documentos" class="sidebar-dropdown list-unstyled collapse "&gt;
                                  &lt;li class="sidebar-item"&gt;&lt;a class="sidebar-link" href="index.html"&gt;Relatório de Inteligência&lt;/a&gt;&lt;/li&gt;
                                  &lt;li class="sidebar-item"&gt;&lt;a class="sidebar-link" href="dashboard-analytics.html"&gt;Informação de Inteligência&lt;/a&gt;&lt;/li&gt;
                                  &lt;li class="sidebar-item"&gt;&lt;a class="sidebar-link" href="dashboard-e-commerce.html"&gt;Pedido de Informação&lt;/a&gt;&lt;/li&gt;
                              &lt;/ul&gt;                                
                      &lt;/ul&gt;
                  &lt;/li&gt;
              &lt;/ul&gt;
          &lt;/div&gt;
      &lt;/nav&gt;
  </code></pre>