【发布时间】:2013-12-01 01:15:41
【问题描述】:
我正在使用 FontAwesome,我的手风琴中有一个图标。所以,我有一个加号图标和一个减号图标。当该类成为“活动标题”时,我希望它仅更改该 h2 的图标。我只是不确定该怎么做,这是我的小提琴和代码。
$('.accordion-header').toggleClass('inactive-header');
var contentwidth = $('.accordion-header').width();
$('.accordion-content').css({'width' : contentwidth });
$('.accordion-header').first().toggleClass('active-header').toggleClass('inactive-header');
$('.accordion-content').first().slideDown().toggleClass('open-content');
$('.accordion-header').click(function () {
if($(this).is('.inactive-header')) {
$('.active-header').toggleClass('active-header').toggleClass('inactive-header').next().slideToggle().toggleClass('open-content');
$(this).toggleClass('active-header').toggleClass('inactive-header');
$(this).next().slideToggle().toggleClass('open-content');
}
else {
$(this).toggleClass('active-header').toggleClass('inactive-header');
$(this).next().slideToggle().toggleClass('open-content');
$(this)
}
});
return false;
我确实认为可以使用 .parent 和 .child 来完成,但我不确定如何去做。
---编辑---
减号图标的 I 代码是:
<i class="fa fa-minus"></i>
【问题讨论】:
标签: javascript jquery html css