JS控制表格隔行变色

<table width="800" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>不变色</td>
</tr>
<tbody id="goaler">
<tr>
<td>xxxxxxxx</td>
</tr>
<tr>
<td>xxxxxxxx</td>
</tr>
<tr>
<td>xxxxxxxx</td>
</tr>
<tr>
<td>xxxxxxxx</td>
</tr>
</tbody>
<tr>
<td>不变色</td>
</tr>
</table>
<script language="JavaScript">
<!--
var TbRow = document.getElementById("goaler");
if (TbRow != null)
{
for (var i=0;i<TbRow.rows.length ;i++ )
{
if (TbRow.rows[i].rowIndex%2==1)
{
TbRow.rows[i].style.backgroundColor="";
}
else
{
TbRow.rows[i].style.backgroundColor="#F1F1F1";
}
}
}
//-->
</script>
posted @ 2011-08-02 22:50  与时俱进  阅读(318)  评论(0编辑  收藏  举报
友情链接:同里老宅院民居客栈