<html>
<head>
<title>点击改变背景颜色</title>
<script type="text/javascript">
function switchcolor(color) {
color.bgColor == '#ececec' ? color.bgColor = '#ffffff' : color.bgColor = '#ececec';
}
</script>
</head>
<body>
<table>
<tr onclick = "switchcolor(this);">
<td>姓名</td>
<td>性别</td>
<td>年龄</td>
</tr>
<tr onclick = "switchcolor(this);">
<td>李华</td>
<td>男</td>
<td>23</td>
</tr>
<tr onclick = "switchcolor(this);">
<td>张梦</td>
<td>女</td>
<td>22</td>
</tr>
</table>
</body>
</html>
<head>
<title>点击改变背景颜色</title>
<script type="text/javascript">
function switchcolor(color) {
color.bgColor == '#ececec' ? color.bgColor = '#ffffff' : color.bgColor = '#ececec';
}
</script>
</head>
<body>
<table>
<tr onclick = "switchcolor(this);">
<td>姓名</td>
<td>性别</td>
<td>年龄</td>
</tr>
<tr onclick = "switchcolor(this);">
<td>李华</td>
<td>男</td>
<td>23</td>
</tr>
<tr onclick = "switchcolor(this);">
<td>张梦</td>
<td>女</td>
<td>22</td>
</tr>
</table>
</body>
</html>