我试图让手风琴标题中的文本在展开和折叠时更改。它可以工作,除非我里面有另一个手风琴,然后它在折叠时都会改变。 http://jsfiddle.net/mwvuH/3/
$(document).ready(function() {
$(".accordion-body").on("show",function(event){
$('span', $(this).prev()).text('-');
});
$(".accordion-body").on("hide",function(event){
$('span', $(this)).text('+');
});
});
HTML
<div class="accordion-heading">
<div class="accordion-toggle" data-toggle="collapse" href="#collapseFive">
Title
<a href="#collapseFive"><span class="pull-right">+</span></a>
</div>
</div>
<div id="collapseFive" class="accordion-body collapse out">
<div class="accordion-inner">
Inside
<div class="accordion-heading">
<div class="accordion-toggle" data-toggle="collapse" href="#collapseSix">
Inside Title
<a href="#collapseSix"><span class="pull-right">+</span></a>
</div>
</div>
<div id="collapseSix" class="accordion-body collapse out">
<div class="accordion-inner">
Inside Inside
</div>
</div>
</div>
</div>