一个jsp页面里面有俩表格 我只想获得tb2的表格数据?表格大概是这样
<table id="tb1">
  <tr> <td>aaaa</td> <td>aabb</td> </tr>
  <tr> <td>bbbb</td> <td>bbcc</td> </tr>
</table>
<table id="tb2">
  <tr> <td>cccc</td> <td>ccdd</td> </tr>
  <tr> <td>ddee</td> <td>eeff</td> </tr>
</table>
只用jquery?把tb2的表格数据都alert出来

解决方案 »

  1.   

    $("#tb2 td").each(function(){
    alert(this.text());
    });
      

  2.   

    debug语法错误 jquery的id选择 好像不能那么玩
      

  3.   

    额,不好意思,错这儿了。$("#tb2 td").each(function(){
    alert($(this).text());//这里错了,呵呵,你再试试。
    });
      

  4.   


    $("#tb2 td").each(function(){
    alert($(this).html());
    });
      

  5.   


    var str="";
    $("#tb2 td").each(function(){
    str+=$(this).html();
    });
    alert(str);
      

  6.   

    $(document).ready(function(){
    $('#testTbBtn').click(function(){
    $("#tb td").each(function(){
    alert($(this).text());
    });
    });
    });
    这是我的源码 这一段还是报语法错误
      

  7.   

    $("#tb td").each(function(){
    你这id没对吧。有tb这个id么?
      

  8.   

    #tb你table上不是这个id吧
    换成3楼写的
      

  9.   

    $('#tb tr').click({ alert("ok");});我记得id选择器 不能这样写的 id只能单独写在括号里面 
    如果能写一起 那上面这句就会弹出东西 但是页面一直都很淡定 什么都没有
    那个tb的id是我自己
    eclipse里面的 tb2是我临时写的
      

  10.   

    怎么不能这么写?$("#tb tr")就是表示选择id为tb下的所有tr元素。
      

  11.   

    悲剧啊  我在edplus里面那样写弹出东西了 myeclipse里面那样写就淡定了 应该还有其他错误 改别人的东西就是麻烦