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

后端 未结 4 1187
萌比男神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条回答
  •  爱一瞬间的悲伤
    2021-02-09 21:48

    So I eventually figured out how to do this, posting it in case it's of help to anyone.

    Alter the HTML to:

    
    

    And then use this JS in the file.

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

提交回复
热议问题