<!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=utf-8" />
<title>隔行换色</title>
<script language="javascript" type="text/javascript">
function changeColor(){
var tab = document.getElementById("tab");
var trs = tab.getElementsByTagName("tr");
for (var i = 0; i < trs.length; i++) {
if (i%2 == 0) {
trs[i].style.backgroundColor = "#F0FFFF";
}else{
trs[i].style.backgroundColor = "#FFFFE0";
}
}
}
</script>
</script>
</head>
<body οnlοad="changeColor()">
<table width="300" border="0" id="tab">
<tr>
<td>1</td>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td>2</td>
<td>2</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>3</td>
<td>3</td>
</tr>
<tr>
<td>4</td>
<td>4</td>
<td>4</td>
</tr>
<tr>
<td>5</td>
<td>5</td>
<td>5</td>
</tr>
</table>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>隔行换色</title>
<script language="javascript" type="text/javascript">
function changeColor(){
var tab = document.getElementById("tab");
var trs = tab.getElementsByTagName("tr");
for (var i = 0; i < trs.length; i++) {
if (i%2 == 0) {
trs[i].style.backgroundColor = "#F0FFFF";
}else{
trs[i].style.backgroundColor = "#FFFFE0";
}
}
}
</script>
</script>
</head>
<body οnlοad="changeColor()">
<table width="300" border="0" id="tab">
<tr>
<td>1</td>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td>2</td>
<td>2</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>3</td>
<td>3</td>
</tr>
<tr>
<td>4</td>
<td>4</td>
<td>4</td>
</tr>
<tr>
<td>5</td>
<td>5</td>
<td>5</td>
</tr>
</table>
</body>
</html>