JSFiddle - React, Tailwind, and code Playground

by Kriti

HTML

<a onclick="changeStyle();"  style="color:red;" class="hearts" >my code</a>

<script>
    status = 1;
function changeStyle() {

//Note the lowercase first letter.
x = document.getElementsByClassName("hearts")[0];

if(status==1) {
    x.style.color = 'green';
    status = 2;
}
else if(status==2) {
    x.style.color = 'yellow';
    status = 1;
}
}
</script>