How to hide bootstrap menu when clicking outside?

How to hide bootstrap menu when clicking outside?
June 26th 19 at 14:17
1 answer
June 26th 19 at 14:19
Solution
something that does not work( - urban_Muell commented on June 26th 19 at 14:22
sorry))) the question is solved thank you) - urban_Muell commented on June 26th 19 at 14:25
and there is the opportunity to slash up to get him? - urban_Muell commented on June 26th 19 at 14:28
slash up

What is it like? - idella_Stoltenberg2 commented on June 26th 19 at 14:31
menu POPs up on top
it's like if clicked outside the field and held up it hides - urban_Muell commented on June 26th 19 at 14:34
and you "slash" with the "swipe" does not confuse? - idella_Stoltenberg2 commented on June 26th 19 at 14:37
there is :D - urban_Muell commented on June 26th 19 at 14:40
: stephen.band/jquery.event.swipe - idella_Stoltenberg2 commented on June 26th 19 at 14:43
:
Tough decision and in addition wrong.
1.
$(document).on('click', function(){
if(!$(this).hasClass('navbar-collapse')){

$(this) , in this case $(document) and how it can have a class .navbar-collapse. You can even if then don't write, there will always be trigger the condition...
2. So hide navigation is $('.navbar-collapse').removeClass('in'); delete class? What attributes are added, any changes to the DOM occur, they do not need to consider?
https://codepen.io/STutukov/pen/PmRzQJ?editors=0010 - Elza44 commented on June 26th 19 at 14:46
It is better to open a js file and add event on click in the field and not disable it when the menu is hidden. - Elza44 commented on June 26th 19 at 14:49

Find more questions by tags BootstrapCSSHTML