求问啊这个如何运行不了.
求问啊,这个怎么运行不了..
------解决方案--------------------
jquery 选择器如果加了【0】就变成原生demo对象,是不能使用jquery的方法的
------解决方案--------------------
<!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 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>
楼主
------解决方案--------------------
- HTML code
<!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>
------解决方案--------------------
jquery 选择器如果加了【0】就变成原生demo对象,是不能使用jquery的方法的
------解决方案--------------------
<!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 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>
楼主
------解决方案--------------------
- JScript code
$(function () { $('table tr:first-child').toggle( function () { $(this).parent().find('tr:gt(0)').hide() }, function () { $(this).parent().find('tr:gt(0)').show() }); });