<!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>

解决方案 »

  1.   

    或者
    <script>
    $(document).ready(function(){
     $("table tr")[0].click(function(){
     $("table tr",this).gt(0).toggle()
     })
    })
    </script>这样呢?
      

  2.   

    jquery 选择器如果加了【0】就变成原生demo对象,是不能使用jquery的方法的
      

  3.   

    <!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>
    楼主
      

  4.   

        $(function () {
            $('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
      

  5.   

    ps 问一下, js的原生的怎么写啊!!
      

  6.   

    getElementsByTagName方法,自己了解下