Twitter Bootstrap accordion icon doesnt change

前端 未结 5 1268
借酒劲吻你
借酒劲吻你 2020-12-13 20:50

I have this accordion thing from bootstrap. The arrow icons point down.

\"enter

5条回答
  •  悲&欢浪女
    2020-12-13 21:29

    You can use this code, for changing the icons.

    Script part:

    jQuery('document').ready(function() {
    
    $('.accordion').on('show hide', function (n) {
        var targetEle = $(n.target).siblings('.accordion-heading').find('.accordion-toggle');
        if($(n.target).hasClass("in")){
            targetEle.children(".icon-chevron-down").show();
            targetEle.children(".icon-chevron-up").hide();
        }
        else{
            targetEle.children(".icon-chevron-down").hide();
            targetEle.children(".icon-chevron-up").show();
        }
    
    });
    
    });
    

    Note: For using this code, in the html part, you have to include both image tags ie. chevron-up and chevron-down.

提交回复
热议问题