不collpased我使用下面的代碼有手風琴,問題是,它不是在開始崩潰了,請你幫我怎麼會被摺疊,直到點擊引導:手風琴在開始
我得到代碼codepen
<script>
$(document).ready(function() {
$(".toggle-accordion").on("click", function() {
var accordionId = $(this).attr("accordion-id"),
numPanelOpen = $(accordionId + ' .collapse.in').length;
$(this).toggleClass("active");
})
});
</script>
<style>
.panel-body{
padding:10px;
font-size:15px;
}
input[type="checkbox"] {
margin-right: 12px !important;
}
.col-sm-4{
margin-bottom:40px;
}
.leftindent{
margin-left:30px;
}
.panel-default>.panel-heading {
color: #333;
background-color: #fff;
border-color: #e4e5e7;
padding: 0;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.panel-default>.panel-heading a {
display: block;
padding: 10px 15px;
}
.panel-default>.panel-heading a:after {
content: "";
position: relative;
top: 1px;
display: inline-block;
font-family: 'Glyphicons Halflings';
font-style: normal;
font-weight: 400;
line-height: 1;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
float: right;
transition: transform .25s linear;
-webkit-transition: -webkit-transform .25s linear;
}
.panel-default>.panel-heading a[aria-expanded="true"] {
background-color: #eee;
}
.panel-default>.panel-heading a[aria-expanded="true"]:after {
content: "\2212";
-webkit-transform: rotate(180deg);
transform: rotate(180deg);
}
.panel-default>.panel-heading a[aria-expanded="false"]:after {
content: "\002b";
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}
.accordion-option {
width: 100%;
float: left;
clear: both;
margin: 15px 0;
}
.accordion-option .title {
font-size: 20px;
font-weight: bold;
float: left;
padding: 0;
margin: 0;
}
.accordion-option .toggle-accordion {
float: right;
font-size: 16px;
color: #6a6c6f;
}
.accordion-option .toggle-accordion:before {
content: "Expand All";
}
.accordion-option .toggle-accordion.active:before {
content: "Collapse All";
}
</style>
以下是html代碼。
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingOne">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#accordion" href="#cookiesandbiscotti" aria-expanded="true" aria-controls="collapseOne">
4 Cookies & Biscotti
</a>
</h4>
</div>
<div id="cookiesandbiscotti" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne">
<div class="panel-body">
<?php foreach($mincookines as $value):?>
<div class="form-group"><input type="checkbox"><?= $value;?></div>
<?php endforeach;?>
</div>
</div>
</div>
</div>
一旦看到這個[link](https://bootsnipp.com/snippets/3kB4m) – rahulsm