<!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=gb2312" />
<title>无标题文档</title>
<style type="text/css">
table{
color:#565;
font:12px Arial, Helvetica, sans-serif;}
td{
background:#dfc;
border-bottom:2px solid #B3DE94;
border-top:3px solid #fff;
padding:9px;
}
td.hover{
background-color:#595;
color:#fff;
}

 

</style>
</head>

<body>

<table summary="book list">
<caption>Book List</caption>
<tr>
<td>Title</td>
<td>ID</td>
<td>Contry</td>
<td>Price</td>
<td>Download</td>
</tr>
<tr>
<td>Tom</td>
<td>526545651</td>
<td>China</td>
<td>price</td>
<td>Download</td>
</tr>
<tr>
<td>Tom</td>
<td>526545651</td>
<td>China</td>
<td>price</td>
<td>Download</td>
</tr>
<tr>
<td>Tom</td>
<td>526545651</td>
<td>China</td>
<td>price</td>
<td>Download</td>
</tr>
<tr>
<td>Tom</td>
<td>526545651</td>
<td>China</td>
<td>price</td>
<td>Download</td>
</tr>
<tr>
<td>Tom</td>
<td>526545651</td>
<td>China</td>
<td>price</td>
<td>Download</td>
</tr>
<tr>
<td>Tom</td>
<td>526545651</td>
<td>China</td>
<td>price</td>
<td>Download</td>
</tr>
</table>
<script language="javascript">
var cells=document.getElementsByTagName('td');//rows是一个行的数组,包含当前页中所有的行
for(var i=0;i<cells.length;i++)
{
cells[i].onmouseover=function()
{
this.className='hover';
//上变色

for(var j=0;j<cells.length;j++)

if(cells[j]==this)
{
cells[j%5].className='hover';
//左变色

cells[j-j%5].className='hover';
}
}

cells[i].onmouseout=function()
{
this.className='';


//上恢复
for(var j=0;j<cells.length;j++)

if(cells[j]==this)
{
cells[j%5].className='';
//左恢复
cells[j-j%5].className='';
}
}
}

</script>
</body>
</html>

posted on 2011-10-13 10:54  小尚  阅读(132)  评论(0编辑  收藏  举报