I am trying to use the Accordion feature in Bootstrap. The problem is that the minus buttons never change to plus upon clicking (and vice versa).
Here is my HTML code:
<div class="container">
<div class="panel-group" id="accordion">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
<span class="glyphicon glyphicon-minus"></span>
Incident Details
</a>
</h4>
</div>
<div id="collapseOne" class="panel-collapse collapse in">
<div class="panel-body">
<table class="table table-bordered">
<tr>
<th>Response Text</th>
<th>Username</th>
<th>Date & Time of Update</th>
</tr>
@if (ViewBag.Data != null)
{
foreach (OfficiumWebApp.Models.ResponseViewModel item in ViewBag.Data)
{
<tr>
<td>@item.ResponseText</td>
<td>@item.Username</td>
<td>@item.DateTimeOfUpdate</td>
</tr>
}
}
</table>
</div>
</div>
</div>
</div>
The JavaScript code here:
<script type="text/javascript">
$(document).ready(function(){
$('.collapse').on('shown.bs.collapse', function () {
$(this).parent().find(".glyphicon-plus").removeClass("glyphicon-plus").addClass("glyphicon-minus");
}).on('hidden.bs.collapse', function () {
$(this).parent().find(".glyphicon-minus").removeClass("glyphicon-minus").addClass("glyphicon-plus");
});
});
</script>
I cant see what I'm doing wrong? Any help would be great!