能不能用css定义一个表格类?

这个类的表格第一行是一种颜色。第二行是一种颜色。其他的行是一种颜色?
能不能用css来定义。
---------------------------------------------------------------

 1<head>
 2<style type="text/css">   
 3<!--   
 4.mytable tr { background-color:expression(mytable(this))}   
 5\-->   
 6</style>
 7<script language="JavaScript">   
 8<!--   
 9//** Power By Fason   
10function mytable(o)   
11{   
12var bg = "green";   
13if (o.rowIndex == 0) {   
14bg = "red";   
15}   
16else if (o.rowIndex == 1)   
17{   
18bg = "blue";   
19}   
20o.style.backgroundColor = bg   
21}   
22//-->   
23</script>
24</head>
 1<body>
 2<table class="mytable" width="100">
 3<tr>
 4<td>1</td>
 5</tr>
 6<tr>
 7<td>2</td>
 8</tr>
 9<tr>
10<td>3</td>
11</tr>
12<tr>
13<td>4</td>
14</tr>
15</table>
16</body>
Published At
Categories with Web编程
Tagged with
comments powered by Disqus