有如下代码<table>
<tr>
<th>asdf</th>
<th>adf</th>
</tr>
<tr>
<td colspan="2">asd<span class="show">sdf</span></td>
</tr>
</table>
怎么样通过
$("table")得到span

解决方案 »

  1.   


    $("table").hover(function(){
          alert($(this).children().children("span").text());
       },
       function(){
       });我大概是希望这样。
    因为一个页面有多个table。
    所以("table span")不行吧。
      

  2.   

    同上("table").hover(function(){
          alert($(this).children().children("span").text());
       },
       function(){
       });
      

  3.   

    1 $("table").find("span") //从查找的角度
    2 $("table").filter(".show") //从过滤的角度
    3 $("table").contains("sdf")//从文本的角度
      

  4.   


    我开始也是这样写的,但就是不对
    取到的是null
    $(this).children()取到的是所有tr  这没错
    然后$(this).children().children()取到的是第一个tr里的所有th...
    但是如果这样 $(this).children().children("th").html()得到是竟然是null
    这我就想不明白了。
    而且  jquery不是还有get(index)的方法吗?  但就是用不了。。
      

  5.   


    为什么用children(".show")方法不行呢?