How to open all accordion by default on page load in javascript
<div class="">
<button class="accordion" ng-click="">
<b>SEARCH BY MONTH</b></button>
<div class="panel">
<!--<p>
<label for="amount">Month range:</label>
</p>-->
<input type="text" id="amount" readonly style="border: 0; color: #f6931f; font-weight: bold;
width: 100%">
<div id="slider-range">
</div>
<br />
<!--Start DateTime : <span id="lblStartDateTime"></span><br />
End DateTime : <span id="lblEndDateTime"></span>-->
</div>
<hr />
<button class="accordion" ng-click="">
<b>SEARCH BY DIVISION</b></button>
<div class="panel" style="margin-top: 1rem">
<table>
<tr ng-repeat="div in divisions">
<td>
<input type="checkbox">
</td>
<td style="padding-left: 5px">
{{div.DIVISION}}
</td>
</tr>
</table>
<br />
</div>
<hr />
<button class="accordion" ng-click="">
<b>SEARCH BY MODEL</b></button>
<div class="panel" style="margin-top: 1rem">
<table>
<tr ng-repeat="model in models">
<td>
<input type="checkbox">
</td>
<td style="padding-left: 5px">
{{model.PRODSHORTNAME}}
</td>
</tr>
</table>
<br />
</div>
<hr />
<button class="accordion" ng-click="">
<b>SEARCH BY MACHINE</b></button>
<div class="panel">
Lorem ipsum...
<br />
</div>
<hr />
<button class="accordion" ng-click="">
<b>SEARCH BY CUSTOMER</b></button>
<div class="panel" style="margin-top: 1rem">
<!--<form class="form-inline my-2 my-lg-0 ml-auto">
<angucomplete-alt id="txtinvnumber"
placeholder="Search Customer Name"
pause="100"
selected-object="Selectcustomer"
remote-url="http://stagingserver:85/EBSApi/api/Warehouse/getAllCustomers"
remote-url-data-field=""
local-data="warehouse"
search-fields="CUSTOMERSHORTNAME"
title-field="CUSTOMERSHORTNAME"
minlength="1"
input-class="form-control mr-sm-2"
match-class="highlight"
ng-click="Search()"></angucomplete-alt>
</form>-->
<table>
<tr ng-repeat="wh in warehouse">
<td>
<input type="checkbox" class="" ng-change="copy($index)" ng-model="wh.hasChecked">
</td>
<td style="padding-left: 5px">
{{wh.CUSTOMERSHORTNAME}}
</td>
</tr>
</table>
<br />
</div>
<hr />
<button class="accordion" ng-click="">
<b>SEARCH BY COMPONENT</b></button>
<div class="panel" style="margin-top: 1rem">
<table>
<tr ng-repeat="cp in customerParts">
<td>
<input type="checkbox">
</td>
<td style="padding-left: 5px">
{{cp.PARTNAME}}
</td>
</tr>
</table>
<br />
</div>
</div>
var acc = document.getElementsByClassName("accordion");
var i;
for (i = 0; i < acc.length; i++) {
acc[i].addEventListener("click", function () {
/* Toggle between adding and removing the "active" class,
to highlight the button that controls the panel */
this.classList.toggle("active");
/* Toggle between hiding and showing the active panel */
var panel = this.nextElementSibling;
if (panel.style.display === "block") {
panel.style.display = "none";
} else {
panel.style.display = "block";
}
});
}