<!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>
解决方案 »
- document.getElementById("id")失效?
- 新手的提交表单问题
- 大家帮忙看看这两段代码有什么区别?
- 请问JS遍历select元素时如何提高效率?
- 高分求助 JavaScript 使 IE控制IE最大化的问题?
- 为什么用e.clientX 在firefox下得不到鼠标的X轴的值,在IE下可以,我引用了event事件啊
- pobj.appendChild(obj)问题
- 请问,如何使用javascript启动客户端的OutLook,并且可以写入mail的内容。
- 多选SELECT中的数据如何保存到数据库
- 级联下拉框选定传值的一个问题~求解~~UPUP
- javascirpt引擎和javascirpt解析器是一个东西吗? 他们有关系吗
- createElement的问题
<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