jquery实现表格弹出隐藏
来源:岁月联盟
时间:2012-03-28
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript" language="javascript" src="../../jquery-1.7.1.min.js"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function(){
$("tr.parent").click(function(){
$(this).siblings(".child-"+this.id).toggle();
});
$("tr[class^=child]").toggle();
});
</script>
</head>
<body>
<table width="300" border="1">
<tr>
<th>ID</th>
<th>name</th>
<th>total</th>
</tr>
<tr id="row1" class="parent">
<td><span>关闭1</span></td>
<td> </td>
<td> </td>
</tr>
<tr class="child-row1">
<td>我们是被弹出来的</td>
<td>我们是被弹出来的</td>
<td>我们是被弹出来的</td>
</tr>
<tr class="parent" id="row2">
<td><span>关闭2</span></td>
<td> </td>
<td> </td>
</tr>
<tr class="child-row2">
<td>我们是被弹出来的</td>
<td>我们是被弹出来的</td>
<td>我们是被弹出来的</td>
</tr>
<tr class="parent" id="row3">
<td><span>关闭3</span></td>
<td>我们是被弹出来的</td>
<td>我们是被弹出来的</td>
</tr>
<tr class="child-row3">
<td>我们是被弹出来的</td>
<td>我们是被弹出来的</td>
<td>我们是被弹出来的</td>
</tr>
<tr class="child-row3">
<td>我们是被弹出来的</td>
<td>我们是被弹出来的</td>
<td>我们是被弹出来的</td>
</tr>
</table>
</body>
</html>
效果图<img src="http://www.2cto.com/uploadfile/2012/0328/20120328092057173.jpg" alt="" />
当点击关闭时就会隐藏“我们是被弹出来的”