在codeigniter中的jquery中的绿色到红色渐变颜色

I calculate data and Fetch from the database and showing in the table in percent format.

Here is my table

<table id="myTable" class="myTable">
<thead>
  <tr class="">
    <th>Types of Work</th>
    <th>value</th>
    <th>Count Percent(%)</th>
    <th>Hours</th>
    <th>Hours Percent(%)</th>
  </tr>
</thead>
<tbody>
<?php $count=0; 
      $count_percent=0;
      $total_time=0;
?>
  <?php foreach($result as $row) { ?>
      <tr>
      <td><?php echo $row->t_name;?></td>
      <td><?php echo $row->NUM;?></td>
      <td><?php echo round($row->count_percent,1)."%";?></td>
      <td><?php echo round($row->value_sum,1);?></td>
      <td><?php echo round($row->duration_percent,1)."%";?></td>
      </tr>
      <?php
        $count += $row->value_sum; 
        $total_time += $row->NUM;  
      } 
      ?>
      <tr>
        <td>Total</td>
        <td><?php echo "$total_time";?></td>
        <td></td>
        <td><?php echo round("$count",1); ?></td>
        <td></td>
      </tr>
</tbody>
</table>

I want Gradient color from Green to red in the table based on percent.

Here is my jquery code:

$(".myTable .valueTD").each(function(){
    var r = Math.min(100,parseInt(this.innerHTML,10)*2+10);
    var g = Math.min(100,200-parseInt(this.innerHTML,10)*2+10);
    this.style.backgroundColor = "rgb(" + g + "%," + r + "%,0%)"
});

I search on google but didn't find the answer.

Please help me to find the solution