我遇到問題。我想將輸入字段中的日期更改爲當前日期。這裏是我的代碼:在輸入類型日期中更改日期HTML
<input type="date" id="datum currentdate">
$(document).ready(function() {
var now = new Date();
var day = ("0" + now.getDate()).slice(-2);
var month = ("0" + (now.getMonth() + 1)).slice(-2);
var today = now.getFullYear()+"-"+(month)+"-"+(day) ;
$('#currentdate').val(today);
});
但是,這是行不通的。我已經包含了jQuery。有誰知道這個問題的解決方案?
什麼意思 「但是,這是行不通的。」? – Jens
它包括tt.mm.jjjj。 – Micha
這是類型=「日期」 – Micha