bootstrap collapse: change display of toggle button icons and text

后端 未结 5 1070
[愿得一人]
[愿得一人] 2021-01-01 23:15

I am using Twitter Bootstrap to create collapsible sections of text. The sections are expanded when a + button is pressed. My html code as follows:

Demo link

5条回答
  •  猫巷女王i
    2021-01-01 23:33

    use this javascript for changing icon

    $(document).ready(function(){
        $("#demo").on("hide.bs.collapse", function(){
            $(".btn").html(' Open');
        });
        $("#demo").on("show.bs.collapse", function(){
            $(".btn").html(' Close');
        });
        $("#demo1").on("hide.bs.collapse", function(){
            $(".btn1").html(' Open');
        });
        $("#demo1").on("show.bs.collapse", function(){
            $(".btn1").html(' Close');
        });
    });
    

提交回复
热议问题