我创建了一个HTML表并在按钮事件上添加了行和列。 这是我的代码:向表中添加新列时,使用默认单元格填充当前行
function AddColumnToDataTable(){
$('#tableHeader').append("<th> Header </th>").attr("contenteditable", true);
// Add a new ColumnHeader and set the property "editable"
}
function AddRowToDataTable(){
var count = $('#tableHeader').find("th").length;
// Get the count of Columns in the table
var newRow = $('#tableBody').append("<tr></tr>");
// Add a new Row
for(var i = 0; i < count ; i++){
newRow.find('tr').last().append("<td> Content </td>").attr("contenteditable", true);
// Fill the cells with a default text and set the property "editable"
}
}
所以我想在添加新列在旧行设置新的细胞。使行自动填充默认文本。
我是否要计算指数? 我有x列,在行y z单元格设置,填补缺少的..?
对不起,我不明白这个问题。我看到你在标题中追加新列,但不在行中。也许呢? – zozo