用checkbox控制表格的背景颜色

<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>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr onClick="choiceColor(check2,this)">
    <td><input type="checkbox" id="check2"></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr onClick="choiceColor(check3,this)">
    <td><input type="checkbox" id="check3"></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr onClick="choiceColor(check4,this)">
    <td><input type="checkbox" id="check4"></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr onClick="choiceColor(check5,this)">
    <td><input type="checkbox" id="check5"></td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>

</body>

</html>

阅读更多
个人分类: 页面显示
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭