Bootstrap Collapse doesn't toggle after you show, hide or toggle from code

后端 未结 3 773
清歌不尽
清歌不尽 2021-02-05 07:20

My HTML is:

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-05 07:44

    1.Try to use collapse() with options, the 'parent' is important

    $("#collapseMenu").collapse({"toggle": true, 'parent': '#navaccordion'});
    $("#collapseQuickLinks").collapse({"toggle": true, 'parent': '#navaccordion' });
    

    Fiddle: http://jsfiddle.net/hieuh25/Xut4C/6/

    2.Basically you have 2 ways:

    • Add class in to that div, e.g:

      cause that div to open.

    • Use collapse() with option 'toggle': true as above, when the div is closed.

    Hope it helps.

提交回复
热议问题