I am currently trying to set up a menu with a icon toggle, so when one icon is clicked it changes to a cross and then when that cross is clicked it changes back to the original. I have got that far, but when I click a new image I want the old icon to reset and the cross to be applied to the new icon.
This is how far I have got:
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingFive">
<a class="collapsed faq-links">
<i id="icon" class="fa fa-info-circle fa-3x"></i>
</a>
</div>
</div>
<br />
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="heading13">
<a class="collapsed faq-links">
<i id="icon" class="fa fa-heartbeat fa-3x"></i>
</a>
</div>
</div>
<br />
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="headingFour">
<a class="collapsed faq-links" >
<i id="icon" class="fa fa-comments fa-3x"></i>
</a>
</div>
</div>
Javascript:
$('.faq-links').click(function(){
var collapsed=$(this).find('i').hasClass('fa-info-circle');
$('.faq-links').find('i').removeClass('fa-times');
$('.faq-links').find('i').addClass('fa-info-circle');
if(collapsed)
$(this).find('i').toggleClass('fa-info-circle fa-3x fa-times fa-3x')
});
I've set up a JSFiddle to show it working https://jsfiddle.net/BenjiBaird/yycf2jb8/1/
So when I click on info-circle the cross is applied and when I click on another that cross is removed. How do I go about applying this so every icon.
Any help would be appreciated, hope I made myself clear.