jQuery add HTML table column

前端 未结 2 1250
栀梦
栀梦 2020-12-04 18:10

I have a HTML table like this:

");
$("#myTable tr:gt(0)").append("");

提交回复
热议问题
DEL
2条回答
  •  南方客
    南方客 (楼主)
    2020-12-04 18:47

    Not related to your question but you can make your HTML bit more semantic.

    DELETE ROWCOL 1 DELETE COLCOL 2 DELETE COLCOL 3 DELETE COLCOL 4 DELETE COLCOL 5 DELETE COLCOL 6
    ROW 1 ROW 1 ROW 1 ROW 1 ROW 1 ROW 1
    ROW 2 ROW 2 ROW 2 ROW 2 ROW 2 ROW 2

    Modified jQuery code may look like:

    var c = $("#myTable thead th").length;
    $("#myTable thead tr").append("
Delete Col "+(c+1)+"Col