<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>New Page 1</title>
<script>
function choiceColor(objChk,objTr){
if(objChk.checked == true) {
objTr.style.background = 'c0c0c0';
}else{
objTr.style.background ='white';
}
}
</script>
</head>
<body>
<table width="408" border=1 style="BORDER-COLLAPSE: collapse">
<tr onClick="choiceColor(check1,this)">
<td><input type="checkbox" id="check1"></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr onClick="choiceColor(check2,this)">
<td><input type="checkbox" id="check2"></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr onClick="choiceColor(check3,this)">
<td><input type="checkbox" id="check3"></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr onClick="choiceColor(check4,this)">
<td><input type="checkbox" id="check4"></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr onClick="choiceColor(check5,this)">
<td><input type="checkbox" id="check5"></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</body>
</html>
此博客展示了一段HTML代码,包含一个表格和JavaScript函数。通过定义的choiceColor函数,当表格行中的复选框被选中时,该行背景变为灰色,未选中则为白色,实现了表格复选框颜色选择的交互功能。
4173

被折叠的 条评论
为什么被折叠?



