您现在的位置: 万盛学电脑网 >> 程序编程 >> 脚本专题 >> javascript >> 正文

鼠标经过tr时,改变tr当前背景颜色

作者:佚名    责任编辑:admin    更新时间:2022-06-22

 本篇文章主要介绍了鼠标经过tr时,改变tr当前背景颜色的示例代码,需要的朋友可以过来参考下,希望对大家有所帮助

示例如下: 代码如下: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=GBK"> <title>鼠标经过给tr换颜色</title>     </head> <body> <table align="center" width="100%" border="1" cellspacing="1" cellpadding="1" >   <tr style="cursor:hand " onmousemove="changeTrColor(this)">     <td align="center">1</td>     <td height="20"> 123</td>     <td height="20"> abvx</td>     <td height="20"> 465465</td>     <td height="20">546654654</td>   </tr>   <tr style="cursor:hand " onmousemove="changeTrColor(this)">     <td align="center">1</td>     <td height="20"> 123</td>     <td height="20"> abvx</td>     <td height="20"> 465465</td>     <td height="20">546654654</td>   </tr>       <tr style="cursor:hand " onmousemove="changeTrColor(this)">     <td align="center">1</td>     <td height="20"> 123</td>     <td height="20"> abvx</td>     <td height="20"> 465465</td>     <td height="20">546654654</td>   </tr> </table> <script type="text/javascript"> function changeTrColor(obj){         var _table=obj.parentNode;     for (var i=0;i<_table.rows.length;i++){         _table.rows[i].style.backgroundColor="";     }         obj.style.backgroundColor="blue"; } </script> </form> </body> </html>