OK to preface I am new to javascript so this may not be the optimal way of doing this...
I am trying to change the color of a material icon when it is clicked. basically I am trying to turn it on and off. The problem is my code while it does find the icon does not read the class...I have tried adding a class, using an id, even a name and it fails to read it. I have see other responses where images are swapped and have tried with the image swap but I just want the color to change.
JAVASCRIPT:
function updateFavorites()
{
if($(this).find($("#staricon")).hasClass('text-warning'))
{
$(this).find($("#staricon")).addClass('text-warning');
}
else
{
$(this).find($("#staricon")).removeClass('text-warning');
}
}
HTML:
<a class=" stats pull-right " href="javacript:void" ><span
onclick="updateFavorites()"><i id="staricon" class="text-warning material-
icons " title="Favorite" >star</i></span></a>