I'm having trouble resolving this situation. I have in my table a list with a radio button, it happens that when selecting an option, it works perfectly coloring the background of the td, but when I select the second option it also selects the background of another td having 2 colored options and only one radio button, simulating a checkbox that is not my case. If you can help me, I'll be very grateful. Thanks!
$(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><inputid="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>