datepicker onclose返回未定义值
我对jQuery datePicker有一个问题,它总是在Onclose函数中返回一个未定义的值:
<input type="text" class="datepicker">
...
$('.datepicker').datepicker({
format: 'yyyy-mm-dd',
firstDay: 1,
minDate: new Date(),
autoClose: true,
onClose: function (date, datepicker) {
alert("Selected Date: " + date);
}
});
日期总是不确定的 - 但是输入字段正确地填充了日期,例如2022-05-16
我做错了什么?如何获得价值?
输入字段没有ID,因为它是动态创建的。
I have an issue with jquery datepicker in materialize, it always returns an undefined value in the onClose function:
<input type="text" class="datepicker">
...
$('.datepicker').datepicker({
format: 'yyyy-mm-dd',
firstDay: 1,
minDate: new Date(),
autoClose: true,
onClose: function (date, datepicker) {
alert("Selected Date: " + date);
}
});
date is always undefined - but the input field is correctly filled with the date, e.g. 2022-05-16
Did I do something wrong? How can I get the value?
The input field does not have an ID, because it is created dynamically.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我复制了您的片段,如您所见,只要您无法复制问题,就不可能进一步帮助您。
I reproduced your snippet, and as you can see it works fine, as long as you are not able to reproduce the issue it will be impossible to help you further.
对我有用:
Works for me: