Bootstrap: Collapse other sections when one is expanded

后端 未结 11 851
一向
一向 2020-11-27 06:28

I am making a Rails app, and am trying to achieve a particular functionality relating to Twitter\'s Bootstrap collapse. Bear with me as I explain it.

I currently hav

11条回答
  •  一个人的身影
    2020-11-27 07:07

    If you don't want to change your markup, this function does the trick:

    jQuery('button').click( function(e) {
        jQuery('.collapse').collapse('hide');
    });
    

    Whenever a BUTTON is clicked, all sections become collapsed. Then bootstrap opens the one you selected.

提交回复
热议问题