1
I’m having a hard time solving this situation. I have in my table a list with radio button, it happens that when selecting an option, it works perfectly coloring the td Background, but when I select the second option it also selects the background of another td having 2 color options and it is selected only a radio button, simulating a checkbox that is not my case. If you can help me, I would be very grateful. Thank you!
$(document).ready(function(){
$('.table tr').click(function(){
$trClass = $(this).attr('class');
if ($trClass == undefined || $trClass == 'desclicado'){
$(this).attr('class', 'clicado');
} else {
$(this).attr('class', 'desclicado');
}
});
});
.clicado{background: #000; color:#fff;}
.desclicado{background: #fff; color: #000;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<table>
<thead>
<tr>
<th>#</th>
<th>Nome</th>
</tr>
</thead>
<tbody>
<tr>
<td><input id="id_bairro" name="id_bairro" value="1" type="radio"/>01</td>
<td>teste 01</td>
</tr>
<tr>
<td><input id="id_bairro" name="id_bairro" value="2" type="radio"/>01</td>
<td>teste 02</td>
</tr>
</tbody>
</table>
Nilson, take a look at the Tour of the website. Remember that in all the questions you ask on the site, you should choose an answer (ONLY ONE) that helped you the most and mark . So it is important to see the Tour page to know how it works.
– Sam