JQuery clear HTML table and insert new rows

前端 未结 1 1796
不知归路
不知归路 2020-12-12 02:39

I have been scouting around but cannot find a solution that works.

I have a simple HTML table:

1条回答
  •  無奈伤痛
    2020-12-12 03:07

    This line is removing the tbody.

    $('#myTable').find('tbody').remove();
    

    So when you get to this line:

    $('#myTable').find('tbody').append(myRow);
    

    There is no tbody to find.

    Change:

    $('#myTable').find('tbody').remove();
    

    To:

    $('#myTable').find('tbody').empty();
    

    0 讨论(0)
提交回复
热议问题