本文介绍了Bootstrap 折叠 - 全部展开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经实施了 Bootstrap 3 Collapse.客户希望在单击任何一个标题链接时扩展所有目标块.我曾尝试实现此答案的修改版本,但无法使其正常工作.

如何在单击任何一个目标块时让所有目标块展开/折叠?

这是标记:

<div class="panel panel-default"><div class="panel-heading"><h6 class="panel-title"><a data-toggle="collapse" data-parent="#accordion" href="#collapse{entry_id}">{title}</a><;/h6>

<div id="collapse{entry_id}" class="panel-collapse collapse"><div class="panel-body">{technology_body}

这是我尝试过的 JS:

$('#accordion').on('click', function() {if($('.collapse:not(.in)')) {$.collapse("切换");}});
解决方案

我在这个问题上得到了一些离线帮助.要使用的脚本是

$('#accordion .panel-default').on('click', function () {$('#accordion .panel-collapse').collapse('toggle');});

这是 JSFiddle 示例 http://jsfiddle.net/gtowle/Vq6gt/1/

I've implemented Bootstrap 3 Collapse. The client wants all of the target blocks to expand when any one of the heading links is clicked. I have tried to implement a modified version of this answer, but can't get it working.

How can I get all target blocks to expand/collapse when any one of them is clicked?

This is the markup:

<div class="panel-group" id="accordion">
    <div class="panel panel-default">
        <div class="panel-heading">
            <h6 class="panel-title"><a data-toggle="collapse" data-parent="#accordion" href="#collapse{entry_id}">{title}</a></h6>
        </div>
    </div>
    <div id="collapse{entry_id}" class="panel-collapse collapse">
      <div class="panel-body">
        {technology_body}
      </div>
   </div>
</div>

And this is the JS I have attempted:

$('#accordion').on('click', function() {
    if($('.collapse:not(.in)')) {
         $.collapse("toggle");
    }
});
解决方案

I got some help offline on this question. The script to use is

$('#accordion .panel-default').on('click', function () {
    $('#accordion .panel-collapse').collapse('toggle');
});

and this is the JSFiddle example http://jsfiddle.net/gtowle/Vq6gt/1/

这篇关于Bootstrap 折叠 - 全部展开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 03:42
查看更多