转自:http://www.cnblogs.com/yzst/archive/2011/10/13/2209684.html
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>鼠标经过时整行变色</title>
<style type="text/css">
table{
color:#565;
font:12px Arial, Helvetica, sans-serif;
}
td{
border-bottom:2px solid #b3de94;
border-top:3px solid #fff;
padding:9px;
}
tr:hover,tr.hover{
background-color:#595;
color:#fff;
}
tr{
background-color:#dfc;
}
</style>
</head>
<body>
<table summary="book list">
<caption>Book List</caption>
<tr>
<td>Title</td>
<td>Tom</td>
<td>Aom</td>
<td>Tina</td>
<td>Os</td>
</tr>
<tr>
<td>tom</td>
<td>1554658</td>
<td>china</td>
<td>$785</td>
<td>download</td>
</tr>
<tr>
<td>tom</td>
<td>1554658</td>
<td>china</td>
<td>$785</td>
<td>download</td>
</tr>
<tr>
<td>tom</td>
<td>1554658</td>
<td>china</td>
<td>$785</td>
<td>download</td>
</tr>
<tr>
<td>tom</td>
<td>1554658</td>
<td>china</td>
<td>$785</td>
<td>download</td>
</tr>
</table><br />
<script language="javascript">
var rows=document.getElementsByTagName('tr');//rows是一个行的数组帮韩当前页中所有的行
for(var i=0;i<rows.length;i++)
{
rows[i].onmouseover=function(){
this.className='hover';
}
rows[i].onmouseout=function(){
this.className='';
}
}
</script>
</body>
</html>