firstly here's the fiddle: http://jsfiddle.net/krish7878/rwz7egdz/1/
What I am trying to do is very simple, there are two div's on with class "panel-heading" and other with class "panel-collapse", there are two conditions,
Condition 1: if 'panel-collapse' has class 'collapse' add some html to 'panel-heading'
Condition 2: if 'panel-collapse' has class 'collapse' add some different html to 'panel-heading'
Here's the code:
HTML:
<div class="panel-heading">
Panel Heading
</div><!-- /.panel-heading-->
<div class="panel-collapse collapse">
Panel Collapse with a just a collapse
</div><!-- /.panel-collapse -->
<br><br>
<div class="panel-heading">
Panel Heading
</div><!-- /.panel-heading-->
<div class="panel-collapse collapse in">
Panel Collapse with collapse & in
</div><!-- /.panel-collapse -->
JS Code:
$( ".panel-heading" ).next().hasClass(".collapse").append( "<i class='fa fa-plus'></i>" );
$( ".panel-heading" ).next().hasClass(".collapse.in").append( "<i class='fa fa-minus'></i>" );
I am quite sure I am missing something in the js part. Any help would be appreciated.