一个页面有多个button,通过var y = t.find("tr :button");得到所有的button,然后向得到其中一个button的value,y.get(0).val();这个方式得不到,求解答,如何才能得到!

解决方案 »

  1.   

    button没有value
    input type="button" 才有value
      

  2.   

    y.get(0).value
    或者y.eq(0).val()
      

  3.   

    y.get(0).val();
    这句代码不对,y.get(0)得到的不是jQuery对象,所以没有val方法,要改成这样:
    y.eq(0).val();
      

  4.   

    <table>
    <tr><td> <input type="button" value="theforever_csdn"></input></td></tr>
    <tr><td> <input type="button" value="theforever_csdn"></input></td></tr>
    </table>
    <script>
    function theforever_csdn() {
    var y = $('#a').find("tr :button");
    alert($(y[0]).val());
    }
    theforever_csdn();
    </script>