The following is my original, reproduced please indicate the source.
/*
* Append rows to the table
*
* @param tableId need to append table ID @param tablerowdata
* Append rows of data (JSON format, need to be discharged in the order of the columns and all already format completed)
*
* @return No
*
*/
function Addtablerow (tableId, Tablerowdata) {
var inserttr = $ (' # ' + tableId + ' Tr:last '). Clone (True);
var Jsonarray = eval ("(" + Tablerowdata + ")");
Set serial number
var tablelength = $ ("#" + tableId). Find ("tr"). Length;
Inserttr.children (' TD '). EQ (0). html (tablelength + 1);
Append the JSON data loop to each column of the table
var i = 1;
for (Var jsonunit in Jsonarray) {
Inserttr.children (' TD '). EQ (i). html (Jsonarray[jsonunit]);
i++;
}
$ (' # ' + tableId + ' Tr:last '). After (inserttr);
}
/*
* Update data for a row in table
*
* @param tableId need to append the ID of table @param rowNum the row number of table should be updated (by default from 1) @param
* Tablerowdata Append rows of data (JSON format, need to be discharged in the order of the columns and all already format completed)
*
* @return No
*
*/
function Upttablerow (tableId, RowNum, Tablerowdata) {
var upttr = $ (' # ' + tableId + ' tr: ' + rowNum);
var Jsonarray = eval ("(" + Tablerowdata + ")");
Append the JSON data loop to each column of the table
var i = 1;
for (Var jsonunit in Jsonarray) {
Upttr.children (' TD '). EQ (i). html (Jsonarray[jsonunit]);
i++;
}
}
jquery implements an append table without using the stitching HTML method