click outside bootstrap menu to close it
<p>I tried to find solution to close bootstrap menu when clicking outside of it(in mobile window size), but cant get it to work, I get it to work when clicking one of the 'a' links by this code:</p>

<pre><code>// menu buttons collapses when clicking a link
    $('document').ready(function() 
{
    if ($('a').on('click', function() 
            { 
                $('.collapse, #mainContainer').removeClass('in'); 
                $('.navbar-toggle').toggleClass('collapsed'); // button
            }));
});
</code></pre>

<p>but how to close menu by clicking outside the menu navbar?</p>

<p>here's my page that shows the problem
<a href="http://www.iwebdesign.se" rel="nofollow noreferrer">iwebdesign.se</a></p>

<p>and yes i tried this already, not working:</p>

<p><a href="https://stackoverflow.com/questions/33824255/bootstrap-how-to-close-an-open-collapsed-navbar-when-clicking-outside-of-the-me">similar question</a></p>