<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>表格高亮显示</title>
<script>
function changecolor(id,flag)
{
if(flag == "over")
document.getElementById(id).style.backgroundColor="red";
else
document.getElementById(id).style.backgroundColor="white";
}
</script>
</head>
<body>
<table border="1" width="500" height="50" align="center">
<thead>
<tr >
<th>编号</th>
<th>姓名</th>
<th>年龄</th>
</tr>
</thead>
<tbody>
<tr onmouseover="changecolor('tr1','over')" id="tr1" onmouseout="changecolor('tr1','out')">
<td>1</td>
<td>张三</td>
<td>22</td>
</tr>
<tr onmouseover="changecolor('tr2','over')" id="tr2" onmouseout="changecolor('tr2','out')">
<td>2</td>
<td>李四</td>
<td>25</td>
</tr>
<tr onmouseover="changecolor('tr3','over')" id="tr3" onmouseout="changecolor('tr3','out')">
<td>3</td>
<td>王五</td>
<td>27</td>
</tr>
<tr onmouseover="changecolor('tr4','over')" id="tr4" onmouseout="changecolor('tr4','out')">
<td>4</td>
<td>赵六</td>
<td>29</td>
</tr>
<tr onmouseover="changecolor('tr5','over')" id="tr5" onmouseout="changecolor('tr5','out')">
<td>5</td>
<td>田七</td>
<td>30</td>
</tr>
<tr onmouseover="changecolor('tr6','over')" id="tr6" onmouseout="changecolor('tr6','out')">
<td>6</td>
<td>汾九</td>
<td>20</td>
</tr>
</tbody>
</table>
</body>
</html>
这里的thead是表头加粗显示