Programmatically toggle bootstrap 3 navigation bar

后端 未结 5 868
一整个雨季
一整个雨季 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:39

    First, add an id to your button tag.

    Than add an id to your collapse div

    Finally you can programmatically click when divCollapse is visible

    if ($('#divCollapse').is(":visible")){
     $('#idToggleButton').click();
    }
    

    Or when is invisible

    if (!$('#divCollapse').is(":visible")){
     $('#idToggleButton').click();
    }
    

提交回复
热议问题