Twitter bootstrap: adding a class to the open accordion title

前端 未结 11 868
-上瘾入骨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条回答
  •  旧时难觅i
    2020-12-08 16:32

    class active dont give the item becouse in less files this class changed you have to give it css instead class. this code is work best and you can add another css that you required

     $(function () {
                $('#accordion')
         .on('show.bs.collapse', function (e) {
             $(e.target).prev('.panel-heading').css({'background-color': 'red','color':'white'})
         })
         .on('hide.bs.collapse', function (e) {
             $(e.target).prev('.panel-heading').css({ 'background-color': '#b6ff00', 'color': 'black' })
         });
            });
    

提交回复
热议问题