Programmatically toggle bootstrap 3 navigation bar

后端 未结 5 872
一整个雨季
一整个雨季 2021-01-18 13:16

I am using few items in my bootstrap 3 navigation bar grouped in like below:

5条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-18 13:50

    As you said, the event will run a modal.

    So, when your modal ( called yourModal ) is showing (before showing), just hide the menu :

    JS :

    $('.yourModal').on('show.bs.modal', function(){
        $('.navbar-collapse').collapse('hide');
    });
    

    Here are the docs :

    http://getbootstrap.com/javascript/#collapse

    http://getbootstrap.com/javascript/#modals-usage

提交回复
热议问题