📜  javascript foreach 表 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:23.478000             🧑  作者: Mango

代码示例2
function createTable(tableData) {
  var table = document.createElement('table');
  var row = {};
  var cell = {};

  tableData.forEach(function(rowData) {
    row = table.insertRow(-1); // [-1] for last position in Safari
    rowData.forEach(function(cellData) {
      cell = row.insertCell();
      cell.textContent = cellData;
    });
  });
  document.body.appendChild(table);
}