I have a table that returns values from my Mysql database without issue. What I want to do is change the font color to green if two of the five values is selected from radio buttons.
The field that I wish to change the color is the "Category" field if the value is either Vegetarian or Vegan. All other options will be the default color (black).
This is my code that displays the table data, which is displaying as I wish:
$richOutput = widgets\RichText::widget(['text' => $post->message, 'record' => $post]);
$richOutput_rname = widgets\RichText::widget(['text' => $post->rname, 'record' => $post]);
$richOutput_category = widgets\RichText::widget(['text' => $post->category, 'record' => $post]); ?>
<table>
<tr><td><span id="post-content-<?php echo $post->id; ?>" <?php print $richOutput; ?></span></font></td></tr>
<tr><td><span id="post-content-rname-<?php echo $post->id; ?>" <?php print $richOutput_rname; ?></span></td></tr>
<tr><td><span id="post-content-category-<?php echo $post->id; ?>" <?php print $richOutput_category; ?></span></td></tr>
</table>
Thank you in advance!
Edit
I tried to add the following JS, but it did not change the text color when the value = "Vegan":
<script type="text/javascript">
$('.cat').each(function(i, n) {
if($(n).text() = "Vegan") $(n).css('color', '#8A1010');
});
</script>