title: Programmatically toggle bootstrap 3 navigation bar
body: <p>I am using few items in my bootstrap 3 navigation bar grouped in like below:</p>
  
  <pre><code>&lt;nav class="navbar navbar-inverse navbar-fixed-top" id="toggleNav" role="navigation"&gt;
          &lt;!-- Brand and toggle get grouped for better mobile display --&gt;
          &lt;div class="navbar-header"&gt;
              &lt;button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse"&gt;
                  &lt;span class="sr-only"&gt;Toggle navigation&lt;/span&gt;
                  &lt;span class="icon-bar"&gt;&lt;/span&gt;
                  &lt;span class="icon-bar"&gt;&lt;/span&gt;
                  &lt;span class="icon-bar"&gt;&lt;/span&gt;
              &lt;/button&gt;
              &lt;a class="navbar-brand" href="#"&gt;Brand name&lt;/a&gt;
          &lt;/div&gt;
          &lt;!-- Collect the nav links, forms, and other content for toggling --&gt;
          &lt;div class="collapse navbar-collapse navbar-ex1-collapse"&gt;                
              &lt;ul class="nav navbar-nav navbar-right"&gt;
                  &lt;li&gt;
                      &lt;a href="javascript:logout();"&gt;&lt;span class="glyphicon glyphicon-log-out"&gt;&lt;/span&gt;&amp;nbsp;Logout&lt;/a&gt;
                  &lt;/li&gt;
                  &lt;li&gt;
                      &lt;a href="#" id="online-offline" toggle="offline"&gt;&lt;span class="glyphicon glyphicon-off"&gt;&lt;/span&gt;&amp;nbsp;Go offline&lt;/a&gt;
                  &lt;/li&gt;
              &lt;/ul&gt;                
          &lt;/div&gt;&lt;!-- /.navbar-collapse --&gt;
      &lt;/nav&gt; 
  </code></pre>
  
  <p>When I click on the second item ('Go offline') I use jquery to invoke a modal window. On mobile I have to first collapse the menu to reach the link, and then when I click on that item I get my modal window correctly. </p>
  
  <p>What I need to achieve is to hide the navbar collapse before showing the modal. Is it possible to programmatically toggle the navbar collapse? How can I do that ?</p>