日期:2014-05-16 浏览次数:20442 次
<!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>
<meta charset="utf-8">
<script scr="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
</head>
<body>
<table>
<tr>
<th>点击隐藏或者显示</th>
</tr>
<tr>
<td>内容</td>
<td>内容:</td>
</tr>
<tr>
<td>内容</td>
<td>内容:</td>
</tr>
</table>
<table>
<tr>
<th>点击隐藏或者显示</th>
</tr>
<tr>
<td class="b_l">内容</td>
<td class="b_l">内容:</td>
</tr>
<tr>
<td class="b_l">内容</td>
<td class="b_l">内容:</td>
</tr>
</table>
<script>
$(function(){
$("table tr",this)[0].toggle(
function(){
$("table tr",this).gt(0).hide()
},
function(){
$("table tr",this).gt(0).show()
}
)
})
</script>
</body>
</html>
$(function () {
$('table tr:first-child').toggle(
function () { $(this).parent().find('tr:gt(0)').hide() },
function () { $(this).parent().find('tr:gt(0)').show() });
});