I have 2 separate div classes called demo-heart and demo-coal. The functionality I am trying to enable: when the user clicks on the fa-heart icon, it turns into fa-coal. When the user clicks on the fa-coal, it turns into fa-heart.
<div class = "demo-heart">
<a href = "#" onclick="myFunction()">
<i class="fa fa-heart fa-3x"></i>
</a>
</div>
<div class = "demo-coal">
<a href = "#" onclick="myFunction()">
<i class="fa fa-coal fa-3x"></i>
</a>
</div>
This is what I ahve so far and it doesn't seem to be working. But I also want it to be able to switch back to the original fa-heart when the user clicks on it. Any suggestions?
<script>
function myFunction(){
$(".demo-heart").html("<a href = '#'><i class='fa fa-coal fa-3x'></i></a>");
}
</script>
divelement, just toggle the class of the andielement.