0
我在PHP中製作一個faq腳本我想在打開面板並關閉面板時更改圖標。我嘗試了這些代碼但未獲得成功。那麼,我的錯誤是什麼碼?更改引導面板的圖標
<div class="col-md-9 col-lg-9 col-sm-12 ">
<?php $v1 = ''; foreach($var as $data){ ?>
<div class="faqHeader" id="<?php echo str_replace(' ','',$data['name']);?>"> <?php echo $data['name'];?> </div>
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
<?php foreach($data['data'] as $dat){ ?>
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingOne">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" href="#col<?php
echo $v1;?>" aria-expanded="true" aria-controls="col<?php
echo $v1;?>">
<span class="glyphicon glyphicon-minus pull-right"></span>
<?php echo $dat['questions'];?>
</a>
</h4>
</div>
<div id="col<?php echo $v1;?>" class="panel-collapse collapse" role="tabpanel" aria-labelledby="headingOne">
<div class="panel-body">
<?php echo $dat['answer'];?>
</div>
</div>
</div>
<?php $v1=$v1+1; } ?>
</div>
<?php } ?>
</div>
<script>
$('.collapse').on('shown.bs.collapse', function(){
$(this).parent().find(".glyphicon-plus").removeClass("glyphicon-plus").addClass("glyphicon-minus");
}).on('hidden.bs.collapse', function(){
$(this).parent().find(".glyphicon-minus").removeClass("glyphicon-minus").addClass("glyphicon-plus");
});
</script>
請幫幫我嗎?