2016-08-06 15 views
1

私は、テーブルをラップするdivブロックを避ける方法を探しています。誰もがこのブロックの動作をテーブルに適用する方法を知っていますか?ブートストラップでdivブロックを折りたたむ代わりにテーブルを折りたたむ

<div class="panel panel-primary"> 
    <div class="panel-heading" role="tab" id="headingTwo"> 
     <h3 class="panel-title"> 
      <a role="button" data-toggle="collapse" 
      href="#collapseTwo" aria-expanded="true" 
      aria-controls="collapseTwo">Requests</a> 
     </h3> 
    </div> 
    <div id="collapseTwo" class="panel-collapse collapse in" 
    role="tabpanel" aria-labelledby="headingTwo"> 
     <table class="table table-bordered"> 
      <thead> 
       <tr> 
        <th>Date</th> 
        <th>Customer</th> 
       </tr> 
      </thead> 
      <tbody> 
       <tr> 
        <td>12/07/16</td> 
        <td>John Smith</td> 
       </tr>   
      </tbody> 
     </table> 
    </div> 
</div> 

答えて

0

私はdatabableすなわちexampleに与えられ、idてきました。 href="#collapseTwo"href="#example"に置き換えて、データテーブルを対象にします。私はまた、データテーブルが圧縮され、醜いように見えるので、クラスcollapseをdataTableから削除するためのjQueryスクリプトを追加しました。あなたがscriptを削除し、その差

$("#example").on('shown.bs.collapse', function(){ 
 
    $(this).removeClass('collapse'); 
 
});
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/> 
 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
 
<div class="panel panel-primary"> 
 
    <div class="panel-heading" role="tab" id="headingTwo"> 
 
     <h3 class="panel-title"> 
 
      <a role="button" data-toggle="collapse" 
 
      href="#example" aria-expanded="true" 
 
      aria-controls="collapseTwo">Requests</a> 
 
     </h3> 
 
    </div> 
 
     <table id="example" class="table table-bordered in"> 
 
      <thead> 
 
       <tr> 
 
        <th>Date</th> 
 
        <th>Customer</th> 
 
       </tr> 
 
      </thead> 
 
      <tbody> 
 
       <tr> 
 
        <td>12/07/16</td> 
 
        <td>John Smith</td> 
 
       </tr>   
 
      </tbody> 
 
     </table> 
 
    </div> 
 
</div>

+0

を参照してください確認したい場合には、感謝を作品!しかし、このソリューションは残念なことに、divブロックを使用してテーブルを折りたたむことで、より多くの副作用が生じます。あなたはこのようにアニメーションを欠場します。 –

+0

私はあなたに同意します – jonju

関連する問題