How do I collapse a table row in Bootstrap?

前端 未结 6 919
予麋鹿
予麋鹿 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:54

    I just came up with the same problem since we still use bootstrap 2.3.2.

    My solution for this: http://jsfiddle.net/KnuU6/281/

    css:

    .myCollapse {
        display: none;
    }
    .myCollapse.in {
        display: block;
    }
    

    javascript:

     $("[data-toggle=myCollapse]").click(function( ev ) {
       ev.preventDefault();
       var target;
       if (this.hasAttribute('data-target')) {
     target = $(this.getAttribute('data-target'));
       } else {
     target = $(this.getAttribute('href'));
       };
       target.toggleClass("in");
     });
    

    html:

    Click me to toggle next row
    You can collapse and expand me.

提交回复
热议问题