Search code examples
javascripttwitter-bootstrapaccordionaccordionpane

how to set first accordion panel to close?


I have 5 accordions and data under each accordion but wat i need is that the all the accordion has to be closed first and when i click the accordion then i need it to be opened.

  <div class="panel panel-default" style="  background: rgba(0,0,0,0.1)">
<div class="panel-heading"  style="background:rgba(0,0,0,0.7);">
  <a data-toggle="collapse" data-parent="#accordion" href="#collapse2">
    <h4 class="panel-title">SUPPLIERS <b class="closed"></b>
    </h4>
  </a>
</div>
<div id="collapse2" class="panel-collapse collapse">
  <div class="panel-body">
      <p class="title"> > BP</p>
     <p class="title"> > CHEVERON </p>
      <p class="title"> > CITGO </p>
       <p class="title"> > EXOON </p>
  </div>
</div>

This is the code sample for the first accordion is there anyway to close the first accordion and open it only on click?


Solution

  • Your need to remove class in from accordion collapse..

    <div id="collapse1" class="accordion-body collapse">