How can I change the table td background color when a radio button is clicked?
This is the view which generates 10 questions having 4 radio buttons each with the help of foreach loop. Making first radio button name ans[0],second ans[1] and so on
<div class="col-lg-8" >
<table class="table" style="width: 100%;">
<?php
$i = 0;
$ques = 1;
echo form_open('Menu/submit_ans', array('name' => 'quiz'));
foreach ($quiz_array as $q){
?>
<td colspan="2"style="background-color: #337ab7;color:white;"><h4>Question No. <?php echo $ques?> </h4></td>
<tr>
<td style="background-color: #D3D3D3;color:white;" colspan="2"><h5><?php echo $q->ques;?></h5></td>
<input hidden name="qid[]" type="text" value="<?php echo $q->qid;?>">
<input hidden name="uid[]" type="text" value="<?php echo $user['id'];?>">
</tr>
<tr>
<td><?php echo $q->ans_1;?></td>
<td><input type="radio" class="myRadio" name="ans[<?php print $q->qid; ?>]" value="1"></td>
</tr>
<tr>
<td><?php echo $q->ans_2;?></td>
<td><input type="radio" class="myRadio" name="ans[<?php print $q->qid; ?>]" value="2"></td>
</tr>
<tr>
<td><?php echo $q->ans_3;?></td>
<td><input type="radio" class="myRadio" name="ans[<?php print $q->qid; ?>]" value="3"></td>
</tr>
<tr>
<td><?php echo $q->ans_4;?></td>
<td><input type="radio" class="myRadio" name="ans[<?php print $q->qid; ?>]" value="4"></td>
<input type="radio" hidden name="ans[<?php print $q->qid; ?>]" value="0" checked="checked">
</tr>
<?php
$i++;
$ques++;
}
?>
</table>
<center><button class="btn btn-success" type="submit">Submit!</button></a></center>
<?php echo form_close();?>
</div>
This is the table data which is in ANOTHER div.
<table class="table">
<tr>
<thead>
<th colspan="10">Answer Status</th>
</thead>
</tr>
<tr>
<td class="color">1</div></td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
<td>10</td>
</tr>
</table>
I want to change the background color of td for 1 when the user clicks the ans[0] radio button.