Add table row in jQuery

前端 未结 30 2258
既然无缘
既然无缘 2020-11-21 05:40

What is the best method in jQuery to add an additional row to a table as the last row?

Is this acceptable?

$(\'#myTable\').append(\'

        
30条回答
  •  迷失自我
    2020-11-21 06:22

    I was having some related issues, trying to insert a table row after the clicked row. All is fine except the .after() call does not work for the last row.

    $('#traffic tbody').find('tr.trafficBody).filter(':nth-child(' + (column + 1) + ')').after(insertedhtml);
    

    I landed up with a very untidy solution:

    create the table as follows (id for each row):

     ... 
     ... 
     ... 
    

    etc ...

    and then :

    $('#traffic tbody').find('tr.trafficBody' + idx).after(html);
    

提交回复
热议问题