I need to just click on checkbox
to paint background
on tr
and on input.
In the code below, it paints only background
of tr
and clicking anywhere in tr
.
<html>
<head>
<script src="//code.jquery.com/jquery-2.1.0.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
<script>
$(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');
}
});
});
</script>
<style>
.clicado{background: #000; color:#fff;}
.desclicado{background: #fff; color: #000;}
</style>
</head>
<body>
<table class="table">
<td><input type="text"></td>
<td><input type="text"></td>
<td><input type="text"></td>
<td><input type="checkbox"></td></tr>
</table>
</body>
</html>