表格伸缩

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>表格伸缩</title>
<script type="text/javascript" src="class library/jquery-1.10.2.min.js"></script>
<script>
$(document).ready(function(){
	$('tr.parent')
	.css('cursor','pointer') //cursor光标
	.attr('title','点击这里展开/关闭') //attr 属性
	.click(function(){
		$(this).siblings('.child-'+this.id).toggle();
	}); //siblings兄弟姐妹
});
</script>
<style>
table.detail, table.detail td, table.detail th {
	border:1px solid #000 ;
}
</style>

</head>

<body>
<table id="detail_table" class="detail" > 
	<col style="width:40px;">
	<col style="width:80px;">
	<col style="width:150px;">
	<col style="width:40px;">
<thead>
	<tr>
		<th>ID</th>
		<th colspan="2">Name</th>
		<th>Total</th>
	</tr>
</thead>
<tbody>
	<tr class="parent" id="row123">
		<td>123</td>
		<td colspan="2">关闭1</td>
		<td>100</td>
	</tr>
	<tr class="child-row123">
		<td> </td>
		<td>2007-01-02</td>
		<td>A short description</td>
		<td>15</td>
	</tr>
	<tr class="child-row123">
		<td> </td>
		<td>2007-02-03</td>
		<td>Another description</td>
		<td>45</td>
	</tr>
	<tr class="child-row123">
		<td> </td>
		<td>2007-03-04</td>
		<td>More Stuff</td>
		<td>40</td>
	</tr>

	<tr class="parent" id="row456">
		<td>456</td>
		<td colspan="2">关闭2</td>
		<td>50</td>
	</tr>
	<tr class="child-row456">
		<td> </td>
		<td>2007-01-02</td>
		<td>A short description</td>
		<td>10</td>
	</tr>
	<tr class="child-row456">
		<td> </td>
		<td>2007-02-03</td>
		<td>Another description</td>
		<td>20</td>
	</tr>
	<tr class="child-row456">
		<td> </td>
		<td>2007-03-04</td>
		<td>More Stuff</td>
		<td>20</td>
	</tr>

	<tr class="parent" id="row789">
		<td>789</td>
		<td colspan="2">关闭3</td>
		<td>75</td>
	</tr>
	<tr class="child-row789">
		<td> </td>
		<td>2007-01-02</td>
		<td>A short description</td>
		<td>33</td>
	</tr>
	<tr class="child-row789">
		<td> </td>
		<td>2007-02-03</td>
		<td>Another description</td>
		<td>22</td>
	</tr>
	<tr class="child-row789">
		<td> </td>
		<td>2007-03-04</td>
		<td>More Stuff</td>
		<td>20</td>
	</tr>
</tbody>
</table>
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值