I have an Awesome Font icon in which I am trying to make the element clickable, change the icon from fa fa-plus
to fa fa-minus
and clicking again, the icon returns to fa fa-plus
. How can I do this?
Here is the code for what I have so far:
$("#fa").click(function(){
var linhaClicada = $(this);
if (linhaClicada.removeClass("fa fa-plus")) {
linhaClicada.addClass("fa fa-minus");
//$("#excluir").hide();
}
else if(linhaClicada.removeClass("fa fa-minus")){
linhaClicada.addClass("fa fa-plus");
}
});
Note: I was able to get it to change from
fa fa-plus
tofa fa-minus
, but I can not get it back tofa fa-plus
when I click back.