<!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>
<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>
<script>
$(document).ready(function(){
$("table tr")[0].click(function(){
$("table tr",this).gt(0).toggle()
})
})
</script>这样呢?
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<script src="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(){
$("tr:eq(0)").toggle(
function(){
$("tr:gt(0)").hide()
},
function(){
$("tr:gt(0)").show()
}
)
})
</script>
</body>
</html>
楼主
$('table tr:first-child').toggle(
function () { $(this).parent().find('tr:gt(0)').hide() },
function () { $(this).parent().find('tr:gt(0)').show() });
});<script scr="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>属性写错了,是src