<div class="codetitle"> <span><a style="CURSOR: pointer" data="66863" class="copybut" id="copybut66863" onclick="doCopy('code66863')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code66863"> <br><script type="text/javascript"> <BR>var name; //存储tr对象的类名,当鼠标移开时进行恢复 <BR>function trcolor(){ //表格行颜色间隔显示 <BR>var tabNode = document.getElementsByTagName("table")[0]; <BR>var trNodes = tabNode.rows; <BR>for(var x=1;x<trNodes.length;x++){ <BR>if(x%2 == 1) <BR>trNodes[x].className = "one" ; <BR>else <BR>trNodes[x].className = "two" ; <BR>trNodes[x].onmouseover = function(){ //高亮显示 <BR>name = this.className; <BR>this.className = "over"; <BR>} <BR>trNodes[x].onmouseout = function(){ //tr对象添加onmouseout事件属性 <BR>this.className = name ; <BR>} <BR>} <BR>} <BR>window.onload = trcolor ; <BR></script> <br><br><style type="text/css"> <BR>table{ width:60%; border:solid 1px #0066FF;} <BR>table td {border:solid 1px #0099ff;} <BR>a{ text-decoration: none;} <BR>.one{background-color: red;} <BR>.two{background-color: blue;} <BR>.over{background-color: yellow;} <BR></style> <br><br> <br> <br><table> <br><tr> <br><td>姓名</td> <td>年龄</td> <td>地址</td> <br> </tr> <br><tr> <br><td>张三</td> <td>23</td> <td>北京</td> <br> </tr> <br><tr> <br><td>李四</td> <td>25</td> <td>上海</td> <br> </tr> <br><tr> <br><td>王五</td> <td>15</td> <td>广州</td> <br> </tr> <br><tr> <br><td>唐总</td> <td>20</td> <td>长沙</td> <br> </tr> <br> </table> <br> <br> </div>