2 回答

TA貢獻1817條經驗 獲得超14個贊
由于您要使用輸入更新的對象是 TD,您應該這樣做:
$(document).on("click", ".edit", function(){
$(this).parents("tr").find("td:not(:last-child, :nth-last-child(2))").each(function(){
let thisVal = $(this).text();
let inputObj = $('<input type="text" class="heading_label-box"/>');
inputObj.val(thisVal);
$(this).html('');
$(this).append(inputObj);
});
$(this).parents("tr").find("td:nth-last-child(3)").each(function(){
let thisVal = $(this).text();
let inputObj = $('<input type="number" class="heading_total-weight"/>');
inputObj.val(thisVal);
$(this).html('');
$(this).append(inputObj);
});
$(this).parents("tr").find(".add, .edit").toggle();
$(".add-heading, .add-point").attr("disabled", "disabled");
});

TA貢獻1895條經驗 獲得超3個贊
似乎輸入類型編號不起作用。
$(this).html('<input type="number" class="heading_total-weight" value="' + $(this).text() + '">');
.text() 返回字符串,因此它不起作用。
添加回答
舉報