Adding open/closed icon to Twitter Bootstrap collapsibles (accordions)

后端 未结 19 2473
失恋的感觉
失恋的感觉 2020-12-22 18:23

I\'ve set up this simple version of the Bootstrap accordion:

Simple accordion: http://jsfiddle.net/darrenc/cngPS/

Currently the icon only po

19条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-22 19:13

    Added to @muffls answer so that this works with all twitter bootstrap collapse and makes the change to the arrow before the animatation starts.

    $('.collapse').on('show', function(){
        $(this).parent().find(".icon-chevron-left").removeClass("icon-chevron-left").addClass("icon-chevron-down");
    }).on('hide', function(){
        $(this).parent().find(".icon-chevron-down").removeClass("icon-chevron-down").addClass("icon-chevron-left");
    });
    

    Depending on your HTML structure you may need to modify the parent().

提交回复
热议问题