答案:<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>行,列換色處理</title>
</head>
<body>
<table width="100%" border="1" cellspacing="0" cellpadding="0" id="Permit_View_Talbe">
<tr >
<td align="center" onClick="Change_TdBgColor(this,document.all.Permit_View_Talbe)" style="cursor:pointer">列頭</td>
<td align="center" onClick="Change_TdBgColor(this,document.all.Permit_View_Talbe)" style="cursor:pointer">列頭</td>
<td align="center" onClick="Change_TdBgColor(this,document.all.Permit_View_Talbe)" style="cursor:pointer">列頭</td>
<td align="center" onClick="Change_TdBgColor(this,document.all.Permit_View_Talbe)" style="cursor:pointer">列頭</td>
</tr>
<tr style="background:#00CC99;color:#FF0000" onMouseOver="Chang_Tr_over(this,document.all.Permit_View_Talbe,1)" onMouseOut="Chang_Tr_over(this,document.all.Permit_View_Talbe,0)">
<td width="25%" height="16">sdfsdfsdfsdfsd</td>
<td width="25%">sdfsdfds</td>
<td width="25%">sdfsd</td>
<td width="25%">sdfsdfsd</td>
</tr>
<tr onMouseOver="Chang_Tr_over(this,document.all.Permit_View_Talbe,1)" onMouseOut="Chang_Tr_over(this,document.all.Permit_View_Talbe,0)">
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr onMouseOver="Chang_Tr_over(this,document.all.Permit_View_Talbe,1)" onMouseOut="Chang_Tr_over(this,document.all.Permit_View_Talbe,0)">
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr onMouseOver="Chang_Tr_over(this,document.all.Permit_View_Talbe,1)" onMouseOut="Chang_Tr_over(this,document.all.Permit_View_Talbe,0)">
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr onMouseOver="Chang_Tr_over(this,document.all.Permit_View_Talbe,1)" onMouseOut="Chang_Tr_over(this,document.all.Permit_View_Talbe,0)">
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr onMouseOver="Chang_Tr_over(this,document.all.Permit_View_Talbe,1)" onMouseOut="Chang_Tr_over(this,document.all.Permit_View_Talbe,0)">
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr onMouseOver="Chang_Tr_over(this,document.all.Permit_View_Talbe,1)" onMouseOut="Chang_Tr_over(this,document.all.Permit_View_Talbe,0)">
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr style="background:#FF00FF;color:#000000" onMouseOver="Chang_Tr_over(this,document.all.Permit_View_Talbe,1)" onMouseOut="Chang_Tr_over(this,document.all.Permit_View_Talbe,0)">
<td>22222</td>
<td>33333</td>
<td>232323</td>
<td>23232</td>
</tr>
<tr onMouseOver="Chang_Tr_over(this,document.all.Permit_View_Talbe,1)" onMouseOut="Chang_Tr_over(this,document.all.Permit_View_Talbe,0)">
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr onMouseOver="Chang_Tr_over(this,document.all.Permit_View_Talbe,1)" onMouseOut="Chang_Tr_over(this,document.all.Permit_View_Talbe,0)">
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr onMouseOver="Chang_Tr_over(this,document.all.Permit_View_Talbe,1)" onMouseOut="Chang_Tr_over(this,document.all.Permit_View_Talbe,0)">
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr onMouseOver="Chang_Tr_over(this,document.all.Permit_View_Talbe,1)" onMouseOut="Chang_Tr_over(this,document.all.Permit_View_Talbe,0)">
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr onMouseOver="Chang_Tr_over(this,document.all.Permit_View_Talbe,1)" onMouseOut="Chang_Tr_over(this,document.all.Permit_View_Talbe,0)">
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr onMouseOver="Chang_Tr_over(this,document.all.Permit_View_Talbe,1)" onMouseOut="Chang_Tr_over(this,document.all.Permit_View_Talbe,0)">
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr onMouseOver="Chang_Tr_over(this,document.all.Permit_View_Talbe,1)" onMouseOut="Chang_Tr_over(this,document.all.Permit_View_Talbe,0)">
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr onMouseOver="Chang_Tr_over(this,document.all.Permit_View_Talbe,1)" onMouseOut="Chang_Tr_over(this,document.all.Permit_View_Talbe,0)">
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr onMouseOver="Chang_Tr_over(this,document.all.Permit_View_Talbe,1)" onMouseOut="Chang_Tr_over(this,document.all.Permit_View_Talbe,0)">
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr onMouseOver="Chang_Tr_over(this,document.all.Permit_View_Talbe,1)" onMouseOut="Chang_Tr_over(this,document.all.Permit_View_Talbe,0)">
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr onMouseOver="Chang_Tr_over(this,document.all.Permit_View_Talbe,1)" onMouseOut="Chang_Tr_over(this,document.all.Permit_View_Talbe,0)">
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr onMouseOver="Chang_Tr_over(this,document.all.Permit_View_Talbe,1)" onMouseOut="Chang_Tr_over(this,document.all.Permit_View_Talbe,0)">
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr onMouseOver="Chang_Tr_over(this,document.all.Permit_View_Talbe,1)" onMouseOut="Chang_Tr_over(this,document.all.Permit_View_Talbe,0)">
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</body>
</html>
<script language="javascript">
//table_tr_td_color.js
//让表的tr和td进行换色
//在页面最下面执行:Init_Table_Tr_Td("Permit_View_Talbe");
//需要换色的行代码:Chang_Tr_over(this,document.all.表id,1)为换色 Chang_Tr_over(this,document.all.表id,0)为恢复原色
//例: <tr onMouseOver="Chang_Tr_over(this,document.all.Permit_View_Talbe,1)" onMouseOut="Chang_Tr_over(this,document.all.Permit_View_Talbe,0)">
//需要换色的列代码:Change_TdBgColor(this,document.all.表id)
//注:行和列的背景色在默認的情況下請用bgcolor和background來定義
//根据需要,可以调整代码里的值是否 for循环里的条件值 -1
//最好是用background
//設置列的換色------------------------
上一个:XML+XSL 与 HTML 两种方案的结合
下一个:又一个不错的js浮动广告代码