How to use jQuery to add a new row to a table, and assgin an incrementing id to it

后端 未结 3 962
春和景丽
春和景丽 2021-01-15 13:50

I have an existing HTML table, part of a form where the user enters GPS points. The user also has the option to upload GPS data points. I\'d like to have a button the user

3条回答
  •  太阳男子
    2021-01-15 14:23

    This should work for adding a single row. You could wrap it in some sort of loop to add multiple:

    function AddRow(xValue,yValue)
    {
    var index = $("#gpsTable tr:last td:first").text();
    var newIndex = parseInt(index) + 1;
    var rowHtml = '
    ' + newIndex + '
    '; rowHtml += '
    '; rowHtml += '
    '; $("#gpsTable tr:last").after(rowHtml); return false; }

提交回复
热议问题