表格整列换颜色
2014-10-09来源:易贤网

查看效果:js实现整列变颜色

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

<title>js整列换颜色</title>

</head><SCRIPT LANGUAGE="JavaScript">

<!--

var tbl = document.getElementById("orderTab"),row=tbl.rows,cel=tbl.getElementsByTagName("td"),W=0;

var H = function(i,cor){for(var n=0,c;c=row[n++];){c.cells[i].style.background=cor;}}

for(var i=0,r;r=cel[i++];){

r.onmouseover = function(){H(W,"#FFF"); W=this.cellIndex; H(W,"red")}

}

//-->

</SCRIPT>

<body>

<table width="549" height="30" align="center" border="1" cellpadding="0" cellspacing="0" id="orderTab">

<tr>

<td>表格整列换颜色</td>

<td>表格整列换颜色</td>

<td class="col">表格整列换颜色</td>

</tr>

<tr>

<td>表格整列换颜色</td>

<td>表格整列换颜色</td>

<td class="col">表格整列换颜色</td>

</tr>

<tr>

<td>表格整列换颜色</td>

<td>表格整列换颜色</td>

<td class="col">表格整列换颜色</td>

</tr>

<tr>

<td>表格整列换颜色</td>

<td>表格整列换颜色</td>

<td class="col">表格整列换颜色</td>

</tr>

<tr>

<td>表格整列换颜色</td>

<td>表格整列换颜色</td>

<td class="col">表格整列换颜色</td>

</tr>

<tr>

<td>表格整列换颜色</td>

<td>表格整列换颜色</td>

<td class="col">表格整列换颜色</td>

</tr>

</table>

</body>

</html>

更多信息请查看IT技术专栏

2025公考·省考培训课程试听预约报名

  • 报班类型
  • 姓名
  • 手机号
  • 验证码
推荐信息