创建一个表格,有表头,数据有8行,5列,当鼠标移动到数据上时,数据所在行更换颜色,鼠标移开恢复原来颜色
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 <script type="text/javascript"> 2 function changeColor(color){ 3 color.style.backgroundColor = "yellow"; 4 } 5 function backColor(color){ 6 color.style.backgroundColor = "white"; 7 } 8 </script> 9 <style type="text/css"> 10 </style> 11 </head> 12 13 <body> 14 <table id = "table" border="1px" cellspacing = "0px" cellpadding = "0px"> 15 <tr height = "40px"> 16 17 <th width="50px" align="center">学号</th> 18 <th width="80px" align="center">姓名</th> 19 <th width="100px" align="center">班级</th> 20 <th width="120px" align="center">专业</th> 21 <th width="150px" align="center">联系方式</th> 22 </tr> 23 24 <tr onmouseover="changeColor(this)" onmouseout="backColor(this)"> 25 <td>1001</td> 26 <td>王艳</td> 27 <td>一班</td> 28 <td>数学教育</td> 29 <td>15245698756</td> 30 31 </tr> 32 <tr onmouseover="changeColor(this)" onmouseout="backColor(this)"> 33 <td>1002</td> 34 <td>张坤</td> 35 <td>五班</td> 36 <td>物理与电子应用</td> 37 <td>18642202134</td> 38 39 </tr> 40 <tr onmouseover="changeColor(this)" onmouseout="backColor(this)"> 41 <td>1003</td> 42 <td>李湘</td> 43 <td>三班</td> 44 <td>商务英语</td> 45 <td>13933215210</td> 46 47 </tr> 48 <tr onmouseover="changeColor(this)" onmouseout="backColor(this)"> 49 <td>1004</td> 50 <td>孙华</td> 51 <td>二班</td> 52 <td>汉语言文学</td> 53 <td>15000210231</td> 54 55 </tr> 56 <tr onmouseover="changeColor(this)" onmouseout="backColor(this)"> 57 <td>1005</td> 58 <td>赵斌</td> 59 <td>六班</td> 60 <td>计算机</td> 61 <td>15145554256</td> 62 63 </tr> 64 <tr onmouseover="changeColor(this)" onmouseout="backColor(this)"> 65 <td>1006</td> 66 <td>刘轩</td> 67 <td>一班</td> 68 <td>数学教育</td> 69 <td>15623232564</td> 70 71 </tr> 72 <tr onmouseover="changeColor(this)" onmouseout="backColor(this)"> 73 <td>1007</td> 74 <td>郑楠</td> 75 <td>一班</td> 76 <td>物业管理</td> 77 <td>13563096535</td> 78 79 </tr> 80 <tr onmouseover="changeColor(this)" onmouseout="backColor(this)"> 81 <td>1008</td> 82 <td>徐颖</td> 83 <td>三班</td> 84 <td>旅游英语</td> 85 <td>15225803142</td> 86 87 </tr> 88 </table> 89 </body>