Auto-close Bootstrap accordion panel when switch to mobile screen size

后端 未结 4 1243
萌比男神i
萌比男神i 2021-02-09 21:20

Using Bootstrap 2.3.2 I have an accordion with a single panel that is open when the page is loaded.

          
4条回答
  •  萌比男神i
    2021-02-09 21:50

    For Bootstrap 3.x this worked great with no change to their example code:

    $(window).bind('resize load', function() {
        if ($(this).width() < 767) {
            $('.collapse').removeClass('in');
            $('.collapse').addClass('out');
        } else {
            $('.collapse').removeClass('out');
            $('.collapse').addClass('in');
        }
    });
    

提交回复
热议问题