从jtml表中获取数据并在jquery中添加行

时间:2014-02-24 16:40:51

标签: javascript jquery html

我有一个html表,在客户端使用Javascript添加了行,但是无法使用jquery获取表的所有值。

http://jsfiddle.net/aghababaei/8kw2p/

这是我的删除行按钮操作:

        $(document).ready(function () {
        $("table.bordered").on("click", ".ibtnDel", function (event) {
            $(this).closest("tr").remove();
            var mydata;
            //gets table

            $("#myTable tr").each(function (row, tr) {
                mydata = mydata
                    + $(tr).find('td:eq(0)').text() + ' '
                    + $(tr).find('td:eq(1)').text() + ' '
                    + $(tr).find('td:eq(2)').text() + ' '
                    + $(tr).find('td:eq(3)').text() + ' '
                    + '\n';
            });
            alert(mydata);
        });});

这是我的html表:

        <table id="myTable" runat="server" class="bordered">
        <thead>
            <tr>
                <td>h1</td>
                <td>h2</td>
                <td>h3</td>
            </tr>
        </thead>
        <tbody></tbody>
        </table>

有解决方案吗?

0 个答案:

没有答案