gpt4 book ai didi

jquery - Bootstrap Accordion 触发器从内部打开/关闭

转载 作者:行者123 更新时间:2023-12-01 04:44:13 24 4
gpt4 key购买 nike

我试图通过单击嵌套在其中的按钮来关闭 Bootstrap 面板。我知道它是可能的,只是无法达到范围。我已经调用了崩溃类,我已经尝试过显示和隐藏它 - 有什么想法吗?

$( "#button1" ).click(function() {
//close accordion 1 and open accordon 3
$("#collapseTwo").collapse();
$("#collapseThree").CollapseIn();
});
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<body>
<div class="bs-example">
<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">1. What is HTML?</a>
</h4>
</div>
<div id="collapseOne" class="panel-collapse collapse in">
<div class="panel-body">
<p>HTML stands for HyperText Markup Language. HTML is the main markup language for describing the structure of Web pages. <a id="button1">Learn more.</a></p>
</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">2. What is Bootstrap?</a>
</h4>
</div>
<div id="collapseTwo" class="panel-collapse collapse">
<div class="panel-body">
<p>Bootstrap is a powerful front-end framework for faster and easier web development. It is a collection of CSS and HTML conventions. <a href="http://www.tutorialrepublic.com/twitter-bootstrap-tutorial/" target="_blank">Learn more.</a></p>
</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">3. What is CSS?</a>
</h4>
</div>
<div id="collapseThree" class="panel-collapse collapse">
<div class="panel-body">
<p>CSS stands for Cascading Style Sheet. CSS allows you to specify various style properties for a given HTML element such as colors, backgrounds, fonts etc. <a href="http://www.tutorialrepublic.com/css-tutorial/" target="_blank">Learn more.</a></p>
</div>
</div>
</div>
</div>
</div>
</body>

最佳答案

你可以试试这个:

$( "#button1" ).click(function() {
//close accordion 1 and open accordion 3
$("#collapseOne, #collapseThree").collapse('toggle');
});

这是fiddle .

<a data-toggle="collapse" data-parent="#accordion" href="#collapseThree" id="button1">Learn more.</a>

这是fiddle .

关于jquery - Bootstrap Accordion 触发器从内部打开/关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32488669/

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