【发布时间】:2012-09-03 00:09:11
【问题描述】:
我将在 Chrome 中的 datepicker 输入 type date 中设置今天的日期。
$(document).ready(function() {
let now = new Date();
let today = now.getDate() + '/' + (now.getMonth() + 1) + '/' + now.getFullYear();
console.log(today);
$('#datePicker').val(today);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input id="datePicker" type="date">
但是,它不起作用。
请在 Chrome 中尝试使用代码 sn-p。
【问题讨论】:
-
如果您在小提琴上选择一个日期并检查结果框架,则执行
$('#datePicker').val();会得到"2012-09-10"而这不是您用于设置日期的格式 -
它在我的终端上运行在 chrome 中..
its not working到底是什么意思? -
试试:
{ currentText: "Now" },见manual -
对我工作...有什么问题?
-
@JigarPandya fr_FR(@user108,另见stackoverflow.com/a/3496622/180100)
标签: javascript html jquery date