在表格中隔行换色(js)
来源:互联网 发布:淘宝网最新版本 编辑:程序博客网 时间:2024/06/10 04:28
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>隔行换色</title>
<script type="text/javascript">
function test()
{
//根据标签得到<tr>
var r=document.getElementsByTagName("tr");
for(var i=0;i<r.length;i++)
{
//定义行数
var j=i+1;
//判断偶数行
if(j%2==0)
{//进行填充颜色
r[i].style.backgroundColor="#0000FF";
}else
{
r[i].style.backgroundColor="brown";
}
}
}
</script>
</head>
<body onload="test()">
<table border="1" id ="bianse">
<tr>
<th>学号</th>
<th>姓名</th>
<th>年龄</th>
<th>地址</th>
<th>成绩</th>
</tr>
<tr>
<th>S001</th>
<th>张三</th>
<th>20</th>
<th>重庆市</th>
<th>90</th>
</tr>
<tr>
<th>S002</th>
<th>李四</th>
<th>20</th>
<th>重庆市</th>
<th>90</th>
</tr>
<tr>
<th>S003</th>
<th>王五</th>
<th>20</th>
<th>重庆市</th>
<th>90</th>
</tr>
<tr>
<th>S003</th>
<th>王五</th>
<th>20</th>
<th>重庆市</th>
<th>90</th>
</tr>
<tr>
<th>S003</th>
<th>王五</th>
<th>20</th>
<th>重庆市</th>
<th>90</th>
</tr>
</table>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title>隔行换色</title>
<script type="text/javascript">
function test()
{
//根据标签得到<tr>
var r=document.getElementsByTagName("tr");
for(var i=0;i<r.length;i++)
{
//定义行数
var j=i+1;
//判断偶数行
if(j%2==0)
{//进行填充颜色
r[i].style.backgroundColor="#0000FF";
}else
{
r[i].style.backgroundColor="brown";
}
}
}
</script>
</head>
<body onload="test()">
<table border="1" id ="bianse">
<tr>
<th>学号</th>
<th>姓名</th>
<th>年龄</th>
<th>地址</th>
<th>成绩</th>
</tr>
<tr>
<th>S001</th>
<th>张三</th>
<th>20</th>
<th>重庆市</th>
<th>90</th>
</tr>
<tr>
<th>S002</th>
<th>李四</th>
<th>20</th>
<th>重庆市</th>
<th>90</th>
</tr>
<tr>
<th>S003</th>
<th>王五</th>
<th>20</th>
<th>重庆市</th>
<th>90</th>
</tr>
<tr>
<th>S003</th>
<th>王五</th>
<th>20</th>
<th>重庆市</th>
<th>90</th>
</tr>
<tr>
<th>S003</th>
<th>王五</th>
<th>20</th>
<th>重庆市</th>
<th>90</th>
</tr>
</table>
</body>
</html>
阅读全文
0 0
- 在表格中隔行换色(js)
- js操作表格目的隔行换色
- 表格隔行换色
- 表格隔行换色
- 表格隔行换色
- 表格隔行换色
- 表格 -隔行换色
- 表格(table)隔行换色
- js隔行换色
- 隔行换色js
- html中用js实现的表格隔行换色
- 用JS完成对表格的隔行换色
- css 表格隔行换色
- jQuery表格隔行换色
- JQuery - 表格隔行换色
- EXCEL 表格隔行换色
- 表格隔行换色效果
- 表格隔行换色效果
- Python Pandas 快速学习笔记
- 重拾Java(4)-线程
- 查看LINUX进程内存占用情况
- metasploit 使用search报错
- 用ButterKnife出现空指针
- 在表格中隔行换色(js)
- SideBarEnhancements
- LinkedList原理及源码解析
- 24点游戏c++
- recovery 升级时间戳校验
- 游戏编程入门(14):创建子画面背景
- Android HFP流程记录
- String to Integer (atoi)
- 非常实用的Java文件操作类