您好,欢迎来到喜迪情感。
搜索
您的当前位置:首页JS控制表格隔行变色的实现代码展示

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>

Copyright © 2019- xdyj.cn 版权所有

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务