0
I’m having a problem, I have a project with several collapses and to indicate opening and closing of the collapses, I put an arrow to the right and while clicking on the text, it turns down and the Collapse opens, however, if you click on the arrow itself, Collapse opens but the image does not change. I wish she’d change along, like I could do?
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);
}
});
I do not believe that the answer was so simple... Thank you so much for the help! I still need to study more JS!
– EduardoBacarin