Response to: How to make this row in GridView in a Grey color when the Checkbox is unchecked?
Revision 1
another solution is using a javascript (jquery) in order to change the color.
a first "scan" of the checkbox
and then check the click event.
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<style type="text/css">
.highlight { background-color:gray; color:#eee;}
</style>
<script type="text/javascript">
$(window).load(function(){
$(document).ready(function() {
Paint();
$("#tabledata :checkbox").click(function () {
$(this).parent('td').parent('tr').toggleClass("highlight");
});
});
function Paint() {
$("#tabledata :checkbox:checked").each(function() {
$(this).parent('td').parent('tr').toggleClass("highlight");
})
}
});
</script>
</head>
<body>
<table id="tabledata">
<tbody>
<tr><td>text1</td><td><input type="checkbox" id="ckb1" class="ckb"></td></tr>
<tr><td>text1</td><td><input type="checkbox" id="ckb2" class="ckb" checked="checked"></td></tr>
<tr><td>text1</td><td><input type="checkbox" id="ckb3" class="ckb"></td></tr>
<tr><td>text1</td><td><input type="checkbox" id="ckb4" class="ckb" checked="checked"></td></tr>
</tbody>
</table>
</body>
</html>
Posted 17-Jul-12 22:48pm
by
nrgjack.