1
I am trying to change the color of the radio button text when losing the selection. It turns out that these radio Buttons are on several tables. The rule is as follows: The screen will be loaded with some a radio button selected per table. When the client selects another radio button, its text should be red. So far ok. The problem is when the original selection comes back, the color of this should turn black again without affecting the text of the other radio Uttons. Just follow my code:
<div id="div1">
<table class="table table-hover table-bordered">
<tbody>
<tr>
<td class="col-md-2"><input type="radio" name="ans" value="0"><label>Dog</label></td>
<td class="col-md-2"><input type="radio" name="ans" value="1" checked="checked"><label>Horse</label></td>
<td class="col-md-2"><input type="radio" name="ans" value="2"><label>Cat</label></td>
</tr>
</tbody>
</table>
</div>
<div id="div2">
<table class="table table-hover table-bordered">
<tbody>
<tr>
<td class="col-md-2"><input type="radio" name="ans2" value="3"><label>Bird</label></td>
<td class="col-md-2"><input type="radio" name="ans2" value="4"><label>Fish</label></td>
<td class="col-md-2"><input type="radio" name="ans2" value="5" checked="checked"><label>Frog</label></td>
</tr>
</tbody>
</table>
</div>
<div id="div3">
<table class="table table-hover table-bordered">
<tbody>
<tr>
<td class="col-md-2"><input type="radio" name="ans3" value="6" checked="checked"><label>Lion</label></td>
<td class="col-md-2"><input type="radio" name="ans3" value="7"><label>Panther</label></td>
<td class="col-md-2"><input type="radio" name="ans3" value="8"><label>Tiger</label></td>
</tr>
</tbody>
</table>
</div>
Jquery:
<script>
var arrayInputs = $('input:radio');
var arrayChecked = $('input:checked');
arrayInputs.change(function() {
var result = $.inArray(this, arrayChecked);
//$('label').css('color','#000');
if(result < 0)
$(this).next('label').css("color", "red");
});
It’s almost that but the Radion Buttons that come checked when the page is loaded should remain black.
– Everton Solon
then it has to be with javascript anyway.. I’ll see if I can make an example here
– tarso64