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

后端 未结 19 2447
失恋的感觉
失恋的感觉 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:14

    Here it's the answer for those who are looking for a solution in Bootstrap 3(like myself).

    The HTML part:

    Some dummy text in here.

    The js part:

    $('.collapse').on('shown.bs.collapse', function(){
    $(this).parent().find(".glyphicon-plus").removeClass("glyphicon-plus").addClass("glyphicon-minus");
    }).on('hidden.bs.collapse', function(){
    $(this).parent().find(".glyphicon-minus").removeClass("glyphicon-minus").addClass("glyphicon-plus");
    });
    

    Example accordion:

    Bootply accordion example

提交回复
热议问题