問(wèn)題似乎是在動(dòng)態(tài)建立新行時(shí),您將輸入欄位的值設(shè)為空字串。這就是為什麼新行不顯示當(dāng)前日期的原因。
您可以修改BtnAdd()函數(shù),將新輸入欄位的值設(shè)定為目前日期。您可以在JavaScript中這樣取得目前日期:
new Date().toISOString().split('T')[0]
.
Take a look:
function BtnAdd() {
/*Add Button*/
var v = $("#TRow").clone().appendTo("#TBody") ;
var currentDate = new Date().toISOString().split('T')[0]; // Get the current date
$(v).find("input").val(currentDate); // Set the value of the new input field to the current date
$(v).find("input").autocomplete({ source: 'backend-script.php' });
$(v).removeClass("d-none");
$(v).find("th").first().html($('#TBody tr').length - 1);
}