gpt4 book ai didi

twitter-bootstrap - bootstrap 3 collapse ('hide' )打开所有可折叠的?

转载 作者:行者123 更新时间:2023-12-04 05:50:33 25 4
gpt4 key购买 nike

我正在尝试实现一些相当简单的事情,但无法理解它 - 谷歌没有任何帮助,而且 Bootstrap 文档似乎有点令人困惑。

我需要的:

  • 简单的可折叠 Accordion ,所有可折叠在页面加载时处于关闭状态
  • 只需单击一个按钮即可关闭所有可折叠项。

  • 问题:
  • 我的解决方案仅在用户打开/关闭一个或多个可折叠文件时才有效
  • 当我调用 collapse('hide') , 所有可折叠元素都已打开 ,除非它们之前已经手动打开过。

  • Jsfiddle .

    我的标记:
    <a class="btn btn-default" id="collapseall"><span class="icon"></span>Collapse 'm all!</a>

    <div class="panel-group" id="accordion">
    <div class="panel panel-default">
    <div class="panel-heading">
    <h4 class="panel-title">
    <a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
    Collapsible Group Item #1
    </a>
    </h4>
    </div>
    <div id="collapseOne" class="panel-collapse collapse">
    <div class="panel-body">
    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.
    </div>
    </div>
    </div>
    <div class="panel panel-default">
    <div class="panel-heading">
    <h4 class="panel-title">
    <a data-toggle="collapse" data-parent="#accordion" href="#collapseTwo">
    Collapsible Group Item #2
    </a>
    </h4>
    </div>
    <div id="collapseTwo" class="panel-collapse collapse">
    <div class="panel-body">
    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.
    </div>
    </div>
    </div>
    <div class="panel panel-default">
    <div class="panel-heading">
    <h4 class="panel-title">
    <a data-toggle="collapse" data-parent="#accordion" href="#collapseThree">
    Collapsible Group Item #3
    </a>
    </h4>
    </div>
    <div id="collapseThree" class="panel-collapse collapse">
    <div class="panel-body">
    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.
    </div>
    </div>
    </div>
    </div>

    Javascript:
    $('#collapseall').click(function () {
    $('.panel-collapse').collapse('hide');
    return false;
    });

    我在这里想念什么?

    最佳答案

    我想你只需要 hide像这样的开放的..

    $('#collapseall').click(function(){
    $('.panel-collapse.in')
    .collapse('hide');
    });

    这是一个有效的打开/关闭所有示例: http://bootply.com/123636

    关于twitter-bootstrap - bootstrap 3 collapse ('hide' )打开所有可折叠的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22966170/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com