Add table row in jQuery

前端 未结 30 2324
既然无缘
既然无缘 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:09

    I'm using this way when there is not any row in the table, as well as, each row is quite complicated.

    style.css:

    ...
    #templateRow {
      display:none;
    }
    ...
    

    xxx.html

    ...
     ... 
    ...
    
    $("#templateRow").clone().removeAttr("id").appendTo( $("#templateRow").parent() );
    
    ...
    

提交回复
热议问题