title: add and remove border-bottom color when div is collapsed in bootstrap accordion
body: <p>I need some help with the bootstrap accordion</p>
  <p>I want to add the <code>border-bottom-color: red</code> for the header of an item <strong>&quot;Collapsible Group Item&quot;</strong> div when it's open<br> and remove it when the div is closed</p>
  <p>I am trying to add the class through Jquery and that class will have the <code>border-bottom-color: red</code> CSS. <br>
  but it's not working, can someone tell me where I am wrong<br></p>
  <p><strong>Expected:<br></strong>
  When the div is open the class will get add else it will get removed <br></p>
  <p><strong>Result of the code I have written:<br></strong>
  The color is getting added to all the div at the same time irrespective of open div<br></p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$('.panel').click(function(){ 
      console.log("hi");      
      if ( $('.panel .panel-collapse').hasClass('show') ){ 
          $('.panel .panel-heading').addClass('add-border-bottom');
          console.log("hello");
      } else {
          $('.panel .panel-heading').removeClass('add-border-bottom');
      }
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>body {
    color: #6a6c6f;
    background-color: #f1f3f6;
    margin-top:30px;
  }
  
  .container {
    max-width: 960px;
  }
  
  
  /* */
  
  .panel-default&gt;.panel-heading {
    color: #333;
    background-color: #fff;
    border-color: #e4e5e7;
    padding: 0;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
  }
  
  .panel-default&gt;.panel-heading a {
    display: block;
    padding: 10px 15px;
  }
  
  .panel-default&gt;.panel-heading a:after {
    content: "";
    position: relative;
    top: 1px;
    display: inline-block;
    font-family: 'Glyphicons Halflings';
    font-style: normal;
    font-weight: 400;
    line-height: 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    float: right;
    transition: transform .25s linear;
    -webkit-transition: -webkit-transform .25s linear;
  }
  
  .panel-default&gt;.panel-heading a[aria-expanded="true"] {
    background-color: #eee;
  }
  
  .panel-default&gt;.panel-heading a[aria-expanded="true"]:after {
    content: "\2212";
    -webkit-transform: rotate(180deg);
    transform: rotate(180deg);
  }
  
  .panel-default&gt;.panel-heading a[aria-expanded="false"]:after {
    content: "\002b";
    -webkit-transform: rotate(90deg);
    transform: rotate(90deg);
  }
  
  .add-border-bottom{
    border-bottom:1px solid red;  
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://code.jquery.com/jquery-2.2.4.min.js"&gt;&lt;/script&gt;
  &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"&gt;&lt;/script&gt;
  &lt;link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.6/dist/css/bootstrap.min.css"&gt;
  
  &lt;div class="container"&gt;
    &lt;div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true"&gt;
      &lt;div class="panel panel-default"&gt;
        &lt;div class="panel-heading" role="tab" id="headingOne"&gt;
          &lt;h4 class="panel-title"&gt;
          &lt;a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne" aria-expanded="true" aria-controls="collapseOne"&gt;
            Collapsible Group Item #1
          &lt;/a&gt;
        &lt;/h4&gt;
        &lt;/div&gt;
        &lt;div id="collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="headingOne"&gt;
          &lt;div class="panel-body"&gt;
            Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird
            on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table,
            raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="panel panel-default"&gt;
        &lt;div class="panel-heading" role="tab" id="headingTwo"&gt;
          &lt;h4 class="panel-title"&gt;
          &lt;a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo"&gt;
            Collapsible Group Item #2
          &lt;/a&gt;
        &lt;/h4&gt;
        &lt;/div&gt;
        &lt;div id="collapseTwo" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingTwo"&gt;
          &lt;div class="panel-body"&gt;
            Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird
            on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table,
            raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="panel panel-default"&gt;
        &lt;div class="panel-heading" role="tab" id="headingThree"&gt;
          &lt;h4 class="panel-title"&gt;
          &lt;a class="collapsed" role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseThree" aria-expanded="false" aria-controls="collapseThree"&gt;
            Collapsible Group Item #3
          &lt;/a&gt;
        &lt;/h4&gt;
        &lt;/div&gt;
        &lt;div id="collapseThree" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingThree"&gt;
          &lt;div class="panel-body"&gt;
            Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird
            on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft beer farm-to-table,
            raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>