<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>表格展开和关闭</title>
<script src="jquery-1.4.2.js"></script>
<script type="text/javascript">
$(function(){
$("tbody>tr.parent").addClass("even");
$("tr.parent").click(function(){
$(this).toggleClass("selected")
.siblings(".child_"+this.id).toggle();
});
});
</script>
<style>
.odd{background:#eee;}
.even{background:#999;}
.selected{background:red;}
</style>
</head>
<body>
<table border="1" cellpadding="0" cellspacing="0" width="100%">
<thead>
<tr>
<th width="30%">姓名</th><th width="30%">性别</th><th width="40%">暂住地</th>
</tr>
</thead>
<tbody>
<tr class="parent" id="row_01">
<td colspan="3">前台设计组</td>
</tr>
<tr class="child_row_01">
<td>张三</td><td>男</td><td>浙江宁波</td>
</tr>
<tr class="child_row_01">
<td>李四</td><td>女</td><td>浙江杭州</td>
</tr>
<tr class="parent" id="row_02">
<td colspan="3">前台开发组</td>
</tr>
<tr class="child_row_02">
<td>王五</td><td>男</td><td>湖南长沙</td>
</tr>
<tr class="child_row_02">
<td>赵六</td><td>女</td><td>湖南耒阳</td>
</tr>
<tr class="parent" id="row_03">
<td colspan="3">后台开发组</td>
</tr>
<tr class="child_row_03">
<td>谢七</td><td>男</td><td>上海</td>
</tr>
<tr class="child_row_03">
<td>小八</td><td>女</td><td>北京</td>
</tr>
</tbody>
</table>
</body>
</html>