jquery表格展开关闭

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><script language="javascript" src="jquery-1.7.1.min.js"></script>
<style type="text/css">
.selected{
background:#FF9900;
cursor:pointer;}
</style>
<script language="javascript">
$(function(){
$("tr.parent").click(function(){
$(this).toggleClass("selected").siblings(".child_"+this.id).toggle();
});
});
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<table>
<thead>
<tr><th>姓名</th><th>性别</th><th>暂住地</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="chile_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>Rain</td><td>男</td><td>浙江杭州</td></tr>
<tr class="child_row_03"><td>David</td><td>女</td><td>浙江上海</td></tr>
</tbody>
</table>
</body>
</html>

你可能感兴趣的:(JavaScript,html,jquery,function,XHTML,Class)