查看效果:js實現(xiàn)整列變顏色
<!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>