Javascript 更改输入类型中的日期日期HTML
我有个问题。我想将输入字段中的日期更改为当前日期。这是我的密码:Javascript 更改输入类型中的日期日期HTML,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我有个问题。我想将输入字段中的日期更改为当前日期。这是我的密码: <input type="date" id="datum currentdate"> 但这不起作用。我已经包括了jQuery。有人知道这个问题的解决方案吗? <input id="currentdate" name="date"> <script type="text/javascript"> document.getElementById('currentdate').value =
<input type="date" id="datum currentdate">
但这不起作用。我已经包括了jQuery。有人知道这个问题的解决方案吗?
<input id="currentdate" name="date">
<script type="text/javascript">
document.getElementById('currentdate').value = Date();
</script>
document.getElementById('currentdate')。值=日期();
输入字段的id必须是currentdate
或datum currentdate
<input type="date" id="currentdate">
什么意思是“但这不起作用?”?它包括tt.mm.jjj。这是type=“date”的标准。您的id无效,id必须是一个唯一的字,但我的代码中的其他内容需要另一个id…@Micha,然后您可以更改字段和jquery中的id。但不要在id中使用空格。现在它可以工作了:D我只是用一个没有ID的类做的。我想添加一些解释会让答案更好。谢谢