我想展示这款可折叠手风琴的第一个元素.我在互联网上做了一些研究但是徒劳无功
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" integrity="sha256-7s5uDGW3AHqw6xtJmNNtr+OBRJUlgkNJEo78P4b0yRw= sha512-nNo+yCHEyn0smMxSswnf/OnX6/KwJuZTlNZBjauKhTK0c+zT+q5JOCx0UFhXQ6rJR9jg6Es8gPuD2uZcYDLqSw==" crossorigin="anonymous"> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha256-KXn5puMvxCw+dAYznun+drMdG1IFl3agK0p/pqT9KAo= sha512-2e8qq0ETcfWRI4HJBzQiA3UoyFk6tbNyG+qSaIBZLyW9Xf3sWZHN/lxe9fTh1U45DpPf07yj94KsUHHWe4Yk1A==" crossorigin="anonymous"></script> <div class="accordion" id="accordion2"> <div class="accordion-group"> <div class="accordion-heading"> <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapSEOne" > Aller au dossier personnel d'un agent </a> </div> <div id="collapSEOne" class="accordion-body collapse" style="height: 0px; "> <div class="accordion-inner"> <form action="goToAgent.do" method="post"> <p align="center"> <input type="hidden" value="identite" name="retour"> <label for="nomPrenom" > Entrer le nom complet de l'agent: </label> <input type="text" name="nomPrenom" class="typeahead" /> <br> <input type="submit" value="appliquer" class="btn btn-info" /> </form> </div> </div> </div> <div class="accordion-group"> <div class="accordion-heading"> <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseTwo"> Ajout d'un nouveau fonctionnaire </a> </div> <div id="collapseTwo" class="accordion-body collapse"> <div class="accordion-inner"> <!-- lorem --> </div> </div> </div> </div>
解决方法
我不认为你已经掌握了手风琴所需的所有HTML,除非你没有将它粘贴在上面.
Bootstrap docs第一个示例将第一个元素设置为打开:
http://twitter.github.com/bootstrap/javascript.html#collapse
我认为这是“在”中的类,它最初是开放的.
<div class="accordion" id="accordion2"> <div class="accordion-group"> <div class="accordion-heading"> <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapSEOne"> Collapsible Group Item #1 </a> </div> <div id="collapSEOne" class="accordion-body collapse in"> <div class="accordion-inner"> Anim pariatur cliche... </div> </div> </div> <div class="accordion-group"> <div class="accordion-heading"> <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseTwo"> Collapsible Group Item #2 </a> </div> <div id="collapseTwo" class="accordion-body collapse"> <div class="accordion-inner"> Anim pariatur cliche... </div> </div> </div> </div>