gpt4 book ai didi

javascript - 添加 'active' 类以打开 Bootstrap Accordion 项

转载 作者:数据小太阳 更新时间:2023-10-29 03:57:55 24 4
gpt4 key购买 nike

我试过这个解决方案:

Twitter bootstrap: adding a class to the open accordion title

但无济于事,有人可以告诉我我在这里做错了什么吗?

这是 Accordion :

<div class="accordion" id="accordion">
<div class="accordion-group">
<div class="accordion-heading">
<div class="row-fluid">
<div class="span5">
<img src="img/smartlist/user-icon.png" class="user"> <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion"
href="#collapseOne">Austin Wang</a>

</div>
<div class="span7">
<img class="envelope" src="img/smartlist/envelope.png"> <a href="#">Seller Drip</a>

<img class="new" src="img/smartlist/new-icon.png"> <a href="#">New</a>

<img class="messages" src="img/smartlist/bubbles.png"> <a href="#">8 Days</a>

<img class="accordion-action pull-right" src="img/smartlist/plus-box.png"
data-toggle="collapse" data-target="#collapseOne">
</div>
</div>
</div>
<div id="collapseOne" class="accordion-body collapse">
<div class="accordion-inner">
<div class="row-fluid">
<div class="span12 top-links"> <a href="#" class="active">Email Template</a>
<a href="#">Home Price Evaluation Offer</a>

</div>
</div>
<div class="arrow-up"></div>
<div class="row-fluid grey-body">
<div class="span12">
<label>Subject</label>
<input type="text" class="text-field">
<label>Body</label>
<textarea rows="10"></textarea>
<div class="buttons">
<div class="form">
<button type="submit" class="send-button">Send</button> <a href="#" class="call">Call</a>
<a href="#" class="skip">Skip</a>

</div>
<div class="pull-right radio">
<input type="radio">
<label>BCC Me</label>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

然后我的 JS 在底部:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="js/less-1.3.3.min.js" type="text/javascript"></script>
<script src="js/bootstrap.js" type="text/javascript"></script>
<script type="text/javascript">
$(".collapse").collapse()
</script>
<script type="text/javascript">
$(function() {

$('.accordion-body').on('show', function (e) {
$(e.target).prev('.accordion-heading').find('.accordion-toggle').addClass('active');
});

$('.accordion-body').on('hide', function (e) {
$(this).find('.accordion-toggle').not($(e.target)).removeClass('active');
});

});
</script>

我真的不太了解 JS,所以非常感谢任何帮助!

最佳答案

如果你在那个 fiddle 中看到,他已经为

定义了一个 css 规则
.active {
background-color: Blue;
}

在您的情况下,您已成功将 css 类应用于元素,但未定义该类。 (或者你没有在问题中发布)

关于javascript - 添加 'active' 类以打开 Bootstrap Accordion 项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15111124/

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