Bootstrap Collapse Not Working with JQuery

Make sure Jquery is included above Bootstrap, it works fine

$('#collapseDiv').collapse("toggle");
.white-link{color:#fff;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>

<div class="container">
  <div class="panel panel-primary">
    <div class="panel-heading" id="panel-head">


      <a data-toggle="collapse" data-target="#collapseDiv" class="white-link" id="toggle">Records Added
                        <span class="indicator glyphicon glyphicon-chevron-down pull-left pad-right" id ="glyphicon"></span>
                    </a>

    </div>


    <div id="collapseDiv" class="panel-collapse collapse">
      <div class="panel-body">

I was having the same problem.... So in JQuery I did something like this:

$('#collapseDiv').removeClass('show');

As mentioned in official doc...

  1. .collapse hides content
  2. .collapsing is applied during transitions
  3. collapse.show shows content

so that is why I removed 'show' class and it worked for me... only drawback is that it hides immediately (without any animation)