$('#dependents-info').on('click', '.btn-edit-dependent', function () {
var currentTD = $(this).parents('tr').find('td');
//what code will I put here?
});
我想在单击“编辑”按钮时使该行可编辑,我该怎么做?
最佳答案
您需要在 td 内创建输入字段,然后当您想要保存它们时,使用 javascript 加载值并存储它们。所以你可以这样做
$('#dependents-info').on('click', '.btn-edit-dependent', function () {
var currentTD = $(this).parents('tr').find('td');
var newInput = currentTD.appendChild("input");
newInput.setAttribute("id","newInput1");
});
关于javascript - 使用javascript单击编辑按钮时如何使行可编辑?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33251491/