How do I collapse a table row in Bootstrap?

前端 未结 6 903
予麋鹿
予麋鹿 2020-12-13 18:29

I am using Bootstrap 2.3.2 in my app and I need to completely hide a row using the collapse plugin. Below is an example:




        
6条回答
  •  無奈伤痛
    2020-12-13 18:32

    You are using collapse on the div inside of your table row (tr). So when you collapse the div, the row is still there. You need to change it to where your id and class are on the tr instead of the div.

    Change this:

    Should be collapsed

    to this:

    Should be collapsed

    JSFiddle: http://jsfiddle.net/KnuU6/21/

    EDIT: If you are unable to upgrade to 3.0.0, I found a JQuery workaround in 2.3.2:

    Remove your data-toggle and data-target and add this JQuery to your button.

    $(".btn").click(function() {
        if($("#collapseme").hasClass("out")) {
            $("#collapseme").addClass("in");
            $("#collapseme").removeClass("out");
        } else {
            $("#collapseme").addClass("out");
            $("#collapseme").removeClass("in");
        }
    });
    

    JSFiddle: http://jsfiddle.net/KnuU6/25/

提交回复
热议问题