鼠标指针经过时整行变色的表格

<style type="text/css">
table{
 color:#565;
 font: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>adddd</td>
<td>tdddd</td>
<td>sdsfd</td>
<td>sfgsd</td>
</tr>
<tr>
<td>tttt</td>
<td>adddd</td>
<td>tdddd</td>
<td>sdsfd</td>
<td>sfgsd</td>
</tr>
<tr>
<td>eeee</td>
<td>adddd</td>
<td>tdddd</td>
<td>sdsfd</td>
<td>sfgsd</td>
</tr>
<tr>
<td>wwww</td>
<td>adddd</td>
<td>tdddd</td>
<td>sdsfd</td>
<td>sfgsd</td>
</tr>
<tr>
<td>qqqqq</td>
<td>adddd</td>
<td>tdddd</td>
<td>sdsfd</td>
<td>sfgsd</td>
</tr>
</table>
<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>

posted on 2011-10-13 09:51  叶璐  阅读(485)  评论(1编辑  收藏  举报