我可以一键关闭两个可折叠面板吗?

时间:2017-02-26 17:55:10

标签: javascript jquery angularjs css3 twitter-bootstrap-3

我的html文件中有3个面板。     第一个面板包含表行(始终打开)。当我按下任何一个表格行时,它旁边的一个新面板打开(折叠)在它旁边,让我们称之为第二个面板。     在第二个面板中,有一个按钮,当单击时,第三个面板在其旁边打开(折叠)到右侧。 当三个面板打开并按下第一个面板中的表格行时,只有第二个面板关闭(折​​叠)。     有没有办法让第三个面板也关闭?

     <html> 
        <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
         <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> 
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0-beta.2/angular.min.js"></script> 
    </head>
    <body>
              
    <div class="row">
    <!-- First Panel -->
        <div class="col-md-4">
            <div class="panel panel-default">
                <div class="panel-heading">First Panel</div>
            	      <div class="panel-body">
            	          <table class="table table-striped">
            	              <thead>
            	                  <tr>
            	                      <th>Name</th>
            	                  </tr>
            	              </thead>
            	              <tbody>
            	                  <tr>
            	                      <td><a data-toggle="collapse"                                                     href="#secondPanel">open second     panel</a>                                     </td>
            	                  </tr>
            	              </tbody>
            	          </table>	
            	      </div>
                </div>
            </div>
            		
            <!-- Second Panel -->
            <div class="col-md-4">
                <div class="panel panel-default panel-collapse collapse"                         id="secondPanel">
                    <div class="panel-heading">Second Panel</div>
                        <div class="panel-body">
                            <table class="table table-striped">
                                <thead>
                                </thead>
                                <tbody>
                                   <button type="button" class="btn btn-primary"                                    data-toggle="collapse"                                                            href="#thirdPanel">Reply</button>			
                                </tbody>
                            </table>					
                        </div>
                    </div>
            </div>
            <!-- Third Panel -->
            <div class="col-md-4">
                <div class="panel panel-default panel-collapse collapse"                         id="thirdPanel">
                    <div class="panel-heading">Third Panel</div>
                        <div class="panel-body">
                            <table class="table table-striped">
                                <thead>
                                </thead>
                                <tbody>
                                    <div class="well well-sm">some text</div>
           	                    </tbody>
                            </table>	
                        </div>
                    </div>
                </div>
            </div>
        </body>
    </html>
        
        

0 个答案:

没有答案