Code:
<html>
<head>
<title></title>
<style type="text/css">
.col1 {
background-Color:white;
}
.col1on {
background-Color:red;
}
.col2 {
background-Color:white;
}
.col2on {
background-Color:green;
}
</style>
<script type="text/javascript">
function InitColor(id,cls){
var table=document.getElementById(id);
var rows=table.rows;
for (var z0=0;z0<rows.length;z0++){
if (rows[z0].className&&rows[z0].className==cls){
rows[z0].onmouseover=function(){ HiLight(rows,cls,true); }
rows[z0].onmouseout=function(){ HiLight(rows,cls,false); }
}
}
}
function HiLight(rows,cls,onoff){
for (var z0=0;z0<rows.length;z0++){
if (rows[z0].className&&(rows[z0].className==cls||rows[z0].className==cls+'on')){
rows[z0].className=cls+(onoff?'on':'');
}
}
}
</script></head>
<body onload="InitColor('tst','col1');InitColor('tst','col2');">
<table id="tst" width="200" border="1" >
<tr class="col1" >
<td>Row 1</td>
</tr>
<tr class="col2">
<td>Row 2</td>
</tr>
<tr class="col1">
<td>Row 3</td>
</tr>
</table>
</body>
</html>
Bookmarks