Twitter bootstrap: adding a class to the open accordion title

前端 未结 11 832
-上瘾入骨i
-上瘾入骨i 2020-12-08 15:58

I am a jquery/javascript newbie. What I want to do is add a class to the open accordion title, and remove it when i open another.

heres the code:

&l         


        
11条回答
  •  攒了一身酷
    2020-12-08 16:36

    This works for me using Bootstrap 3.3.6,

     $('#accordion')
       .on('show.bs.collapse', function (e) {
           $(e.target).parent('.panel').addClass('panel-primary');
       })
       .on('hide.bs.collapse', function (e) {
           $(e.target).parent('.panel').removeClass('panel-primary');
       });
            });
    

提交回复
热议问题