我有這個問題:我的移動應用程序有一些基於Bootstrap的手風琴。默認行爲使得摺疊和展開僅適用於內部鏈接,而不是完整的標題面板。我需要改變這種情況,當用戶點擊標題面板的任何部分時,手風琴就會展開並摺疊。Bootstrap手風琴點擊標題面板展開/摺疊
0
A
回答
0
我附帶這個解決方案。它不是很優雅,但工作。
HTML
<div class="panel panel-default">
<div class="panel-heading" onclick="javascript: expandAccordion(' HospitalsAcc ')">
<a class="panel-title" data-toggle="collapse" data-parent="#TopStories" href="#HospitalsAcc">Hospitals</a>
</div>
<div id="HospitalsAcc" class="panel-collapse collapse" style="height: 0px;">
<div class="panel-body" style="text-align: center">
<p style="text-align: justify; margin: 0px">GeometryIndex: 1 </p>
<p style="text-align: justify; margin: 0px">NAME: HOSPITAL </p>
<p style="text-align: justify; margin: 0px">ADDRNO: 00 </p>
</div>
</div>
JS
function expandAccordion(param) {
param = param.trim();
$('#'+param).collapse('toggle')
};
1
嗯,這是一個有點晚回覆你的答案,但是,這將是爲未來幫助。 如果我正確理解你的問題,你需要一個自舉手風琴,在點擊面板標題時展開和摺疊。那麼這裏是代碼:
\t function toggleIcon(e) {
$(e.target)
.prev('.panel-heading')
.find(".more-less")
.toggleClass('glyphicon-plus glyphicon-minus');
}
$('.panel-group').on('hidden.bs.collapse', toggleIcon);
$('.panel-group').on('shown.bs.collapse', toggleIcon);
\t .panel-group .panel {
\t \t border-radius: 0;
\t \t box-shadow: none;
\t \t border-color: #EEEEEE;
\t }
\t .panel-default > .panel-heading {
\t \t padding: 0;
\t \t border-radius: 0;
\t \t color: #212121;
\t \t background-color: #FAFAFA;
\t \t border-color: #EEEEEE;
\t }
\t .panel-title {
\t \t font-size: 14px;
\t }
\t .panel-title > a {
\t \t display: block;
\t \t padding: 15px;
\t \t text-decoration: none;
\t }
\t .more-less {
\t \t float: right;
\t \t color: #212121;
\t }
\t .panel-default > .panel-heading + .panel-collapse > .panel-body {
\t \t border-top-color: #EEEEEE;
\t }
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container demo">
\t
\t <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
\t \t <div class="panel panel-default">
\t \t \t <div class="panel-heading" role="tab" id="headingOne">
\t \t \t \t <h4 class="panel-title">
\t \t \t \t \t <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
\t \t \t \t \t \t <i class="more-less glyphicon glyphicon-plus"></i>
\t \t \t \t \t \t Collapsible Group Item #1
\t \t \t \t \t </a>
\t \t \t \t </h4>
\t \t \t </div>
\t \t \t <div id="collapseOne" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingOne">
\t \t \t \t <div class="panel-body">
\t \t \t \t \t Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
\t \t \t \t </div>
\t \t \t </div>
\t \t </div>
\t \t <div class="panel panel-default">
\t \t \t <div class="panel-heading" role="tab" id="headingTwo">
\t \t \t \t <h4 class="panel-title">
\t \t \t \t \t <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
\t \t \t \t \t \t <i class="more-less glyphicon glyphicon-plus"></i>
\t \t \t \t \t \t Collapsible Group Item #2
\t \t \t \t \t </a>
\t \t \t \t </h4>
\t \t \t </div>
\t \t \t <div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo">
\t \t \t \t <div class="panel-body">
\t \t \t \t \t Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
\t \t \t \t </div>
\t \t \t </div>
\t \t </div>
\t \t <div class="panel panel-default">
\t \t \t <div class="panel-heading" role="tab" id="headingThree">
\t \t \t \t <h4 class="panel-title">
\t \t \t \t \t <a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
\t \t \t \t \t \t <i class="more-less glyphicon glyphicon-plus"></i>
\t \t \t \t \t \t Collapsible Group Item #3
\t \t \t \t \t </a>
\t \t \t \t </h4>
\t \t \t </div>
\t \t \t <div id="collapseThree" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingThree">
\t \t \t \t <div class="panel-body">
\t \t \t \t \t Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
\t \t \t \t </div>
\t \t \t </div>
\t \t </div>
\t </div><!-- panel-group -->
\t
\t
</div><!-- container -->
相關問題
- 1. Bootstrap手風琴面板/摺疊
- 2. 波旁手風琴點擊一次展開/摺疊點擊
- 3. Bootstrap手風琴不折疊?
- 4. 如何在摺疊/摺疊時更改Bootstrap手風琴標題
- 5. Bootstrap手風琴摺疊高度問題
- 6. 摺疊/展開的手風琴菜單
- 7. Jquery UI手風琴展開/摺疊
- 8. 展開時手風琴摺疊菜單側面圖標更改
- 9. 手風琴展開摺疊圖標問題
- 10. bootstrap手風琴:如何摺疊所有點擊
- 11. Ui-Bootstrap文檔點擊摺疊手風琴
- 12. bootstrap手風琴摺疊多個孩子?
- 13. Bootstrap摺疊手風琴沒有響應
- 14. bootstrap手風琴已全部摺疊
- 15. 帶Bootstrap的Thymeleaf:摺疊/手風琴表
- 16. Bootstrap 3:摺疊手風琴不工作
- 17. Twitter bootstrap手風琴摺疊功能
- 18. Bootstrap 2手風琴菜單摺疊
- 19. Twitter bootstrap手風琴不折疊
- 20. 點擊鏈接摺疊已擴展的手風琴
- 21. BootStrap手風琴面板
- 22. jQuery的手風琴摺疊和展開問題(親子中心)
- 23. 手風琴一次打開一個面板使用摺疊
- 24. bootstrap手風琴圖標更改點擊
- 25. 手風琴內手風琴摺疊父母手風琴
- 26. 如何在單擊整個標題div時使Bootstrap v4手風琴摺疊?
- 27. Jquery UI手風琴摺疊前打開
- 28. Jquery UI手風琴不開始摺疊
- 29. 動態手風琴摺疊
- 30. 摺疊jQuery的手風琴