Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>just use this code:</p> <pre><code>&lt;script&gt; $('.nav a').click(function () { $(".navbar-to-collapse").collapse("hide") }); &lt;/script&gt; </code></pre> <p>you can change <strong>.nav a</strong> and <strong>.navbar-to-collapse</strong> with your desired variable or add to them more variable simply by using &lt; <strong>,</strong> > between each variable .</p> <p>more explanation:</p> <ol> <li><p><strong>.nav a</strong> is the variable that you target by your click and in this example it's a <strong>link</strong> under a <strong>nav</strong> class, you can modify it to target a link using ID not class </p> <pre><code>$('#nav a') </code></pre></li> <li><p><strong>.navbar-to-collapse</strong> is the value for <strong>data-target=</strong> <em>".navbar-to-collapse"</em> and you can modify it to the data-target you use.</p></li> </ol> <p>so a complete example (for illustrating ) should be like that:</p> <pre><code>&lt;header&gt;&lt;!-- /Navigation-Bar Container--&gt; &lt;nav class="navbar navbar-default navbar-fixed-top" role="navigation"&gt; &lt;div class="container"&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-to-collapse"&gt; &lt;span class="sr-only"&gt;Toggle navigation&lt;/span&gt; &lt;i class="icon-menu"&gt;&lt;/i&gt; &lt;/button&gt; &lt;/div&gt; &lt;div class="collapse navbar-collapse navbar-to-collapse"&gt; &lt;ul class="nav"&gt; &lt;li&gt;&lt;a href="#"&gt;Link 1&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Link 2&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Link 3&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;Link 4&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;/div&gt;&lt;!-- /.navbar-collapse --&gt; &lt;/div&gt; &lt;/nav&gt; </code></pre> <p></p> <p>and use the script :</p> <pre><code>&lt;script&gt; $('.nav a').click(function () { $(".navbar-to-collapse").collapse("hide") }); &lt;/script&gt; </code></pre> <p>hope it will help you</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload