I am writing php code for bootstrap collapse and taking error Cannot read property 'querySelectorAll' of null. I spend really a lot of time to this simple problem. If I put without php that is working really norm without error Error is:
Uncaught TypeError: Cannot read property 'querySelectorAll' of null
at a.t._getParent (collapse.js:300)
at new a (collapse.js:88)
at HTMLDivElement.<anonymous> (collapse.js:345)
at Function.each (jquery.js:368)
at jQuery.fn.init.each (jquery.js:157)
at jQuery.fn.init.a._jQueryInterface [as collapse] (collapse.js:331)
at HTMLDivElement.<anonymous> (collapse.js:378)
at Function.each (jquery.js:368)
at jQuery.fn.init.each (jquery.js:157)
at HTMLButtonElement.<anonymous> (collapse.js:374)
That is my php code
<div id="info-content" class="accordion" id="accordionExample">
<?
$faqs = get_field('faqs');
foreach ($faqs as $key => $value):
?>
<div class="card">
<div class="card-header" id="headingOne<?=$key;?>">
<h5 class="mb-0">
<button class="btn btn-link" type="button" data-toggle="collapse" data-target="#collapseOne<?=$key;?>" aria-expanded="true" aria-controls="collapseOne<?=$key;?>">
<?=$value['question'];?>
</button>
</h5>
<i class="fas fa-plus"></i>
</div>
<div id="collapseOne<?=$key;?>" class="collapse <?if($key==0):?>show<?endif;?>" aria-labelledby="headingOne<?=$key;?>" data-parent="#accordionExample">
<div class="card-body">
<?=$value['answer'];?>
</div>
</div>
</div>
<?endforeach;?>
</div>