[英]How to set the input control of type datetime-local to the current time
[英]Set input type of datetime-local programmatically
我有一個表單輸入字段type=datetime-local
。 我想將其設置為某個時間並讓實際的字段更新以反映該時間。
我努力了:
<input type="datetime-local" class="form-input">
我試圖設置它使用以下測試:
document.querySelector(".form-input").value = "1955-05-24T12:15";
我沒有收到任何錯誤,但該字段未顯示此日期。
你的代碼對我有用。 確保 js 代碼在元素創建后運行。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.