【发布时间】:2018-07-02 05:42:05
【问题描述】:
我正在尝试通过单击链接来打开一些 Bootstrap Toggle 链接,并通过再次单击该链接来折叠。它可以很好地打开和关闭。我有 3 个链接可以打开和折叠。如果我点击 Link1 ,切换正在打开,接下来我单击 Link2,该切换也打开而不关闭与第一个链接相关的切换.. 我知道我缺少一些功能.. 但在任何地方都找不到确切的解决方案.. 在这里我给出了源代码...
<div class="bd-example" data-example-id="">
<p>
<button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample">
Button 1
</button>
<button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#collapseExample2" aria-expanded="false" aria-controls="collapseExample">
Button 2
</button>
<button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#collapseExample3" aria-expanded="false" aria-controls="collapseExample">
Button 3
</button>
</p>
<div class="collapse" id="collapseExample">
<div class="card card-block">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.
</div>
</div>
<div class="collapse" id="collapseExample2">
<div class="card card-block">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident 2.
</div>
</div>
<div class="collapse" id="collapseExample3">
<div class="card card-block">
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident 3.
</div>
</div>
</div>
【问题讨论】:
-
getbootstrap.com/docs/4.0/components/collapse 第二个例子告诉你如何控制多个目标,不确定你使用的是什么版本的引导程序?
-
@sore-spot 我在这里使用的相同链接代码..
-
您还没有使用 id 将一个按钮用于一个切换,在示例中,第三个按钮使用类来定位它们。看起来您想要一个手风琴,请查看该页面上的第三个示例。
-
@sore-spot ---检查了第三个例子,同样它没有通过点击第二个链接关闭......两个链接都在打开..我想做的是,我点击在第二个链接上,第一个链接必须关闭..
标签: javascript jquery html css twitter-bootstrap