Add table row in jQuery

前端 未结 30 2327
既然无缘
既然无缘 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条回答
  •  -上瘾入骨i
    2020-11-21 06:05

    So things have changed ever since @Luke Bennett answered this question. Here is an update.

    jQuery since version 1.4(?) automatically detects if the element you are trying to insert (using any of the append(), prepend(), before(), or after() methods) is a and inserts it into the first in your table or wraps it into a new if one doesn't exist.

    So yes your example code is acceptable and will work fine with jQuery 1.4+. ;)

    $('#myTable').append('my datamore data');
    

提交回复
热议问题