我有一个包含选项卡的可折叠元素,其中可折叠元素在标题文本的左侧有一个图标(图标箭头向下)。当您折叠此元素时,图标将变为 icon-arrow-up。它工作得很好,但是,当我在选项卡之间切换时,图标也会改变。
这是我的 jsFiddle:http: //jsfiddle.net/m6R44/
<div class="well">
<h3>
<span class="icon-arrow-down" data-toggle="collapse" data-target="#collapseH" id="collapseP"></span>
<a href="#">Lorem Ipsum</a>
</h3>
<div id="collapseH" class="collapse in">
<ul class="nav nav-tabs" id="ic_tabs">
<li class="active"><a href="#paragraph1" data-toggle="tab">Paragraph 1</a></li>
<li><a href="#paragraph2" data-toggle="tab">Paragraph 2</a></li>
<li><a href="#paragraph3" data-toggle="tab">Paragraph 3</a></li>
</ul>
<div id="ic_tabsContent" class="tab-content">
<div class="tab-pane fade in active" id="paragraph1">
content 1
</div>
<div class="tab-pane fade" id="paragraph2">
content 2
</div>
<div class="tab-pane fade" id="paragraph3">
content 3
</div>
</div>
</div>
</div>
<script>
$('#collapseH').on('show hide', function(e){
$('#collapseP').toggleClass('icon-arrow-up icon-arrow-down', 200);
});
</script>