I have a problem, I have a project with several collapses and to indicate opening and closing of the collapses, I placed an arrow to the right and when clicking on the text, it flips down and the collapse opens, however, own arrow, the collapse opens however the image does not change. I would like her to change together, how could I do it?
Collapse HTML code
<h1 index="1" class="collapsed change" data-toggle="collapse" data-parent="#accordion"
href="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo" ng-click="alert_step2()">
<img index="1" class="change img-change" src="assets/img/arrow_right.png"
style="width: 20px; height: 25px">Step 2 - Acknowledge Your Strengths (highest scores)</h1>
</h1>
JS code for image exchange
$('.change').click(function (){
var img1 = 'assets/img/arrow_right.png';
var img2 = 'assets/img/arrow_down.png';
var index = $(this).attr('index');
var element = $('img[index='+index+']');
if(element.attr('src') === img1){
element.attr('src',img2);
}else if(element.attr('src') === img2){
element.attr('src',img1);
}
});