更新时间:2022-02-19 23:08:47
这是因为 currDate
可能是空的。
如果 currDate
是emtpy $('。currDate')。datepicker('getDate')
将返回 null
在这种情况下 date2.setDate(date2.getDate()+ 1);
可能会抛出错误
If currDate
is emtpy $('.currDate').datepicker('getDate')
will return null
in which case date2.setDate(date2.getDate()+1);
could throw the error
更新:
$(function() {
$('#nxtDate').datepicker({
dateFormat: "dd-M-yy",
});
$("#currDate").datepicker({
dateFormat: "dd-M-yy",
minDate: 0,
onSelect: function(date){
var date2 = $('#currDate').datepicker('getDate');
date2.setDate(date2.getDate()+1);
$('#nxtDate').datepicker('setDate', date2);
}
});
})