我正在尝试在我的网站上实现日期选择,但我遇到了一个小问题:要让它出现,我必须单击文本字段,单击外部,然后再次单击内部以显示。我该如何解决?这是我的代码的一部分:
function datePicker(){
$( "#from" ).datepicker({
defaultDate: "+1w",
changeMonth: true,
changeYear: true,
onClose: function( selectedDate ) {
$( "#to" ).datepicker( "option", "minDate", selectedDate );
$( "#to" ).datepicker( "option", "dateFormat", "dd/mm/yy" );
}
});
$( "#to" ).datepicker({
defaultDate: "+1w",
changeMonth: true,
changeYear: true,
onClose: function( selectedDate ) {
$( "#from" ).datepicker( "option", "maxDate", selectedDate );
$( "#from" ).datepicker( "option", "dateFormat", "dd/mm/yy" );
}
});
}
<input type="text" class ="date" id= "from" name="from" onclick="datePicker();"/>
<BR>
<input type="text" class = "date" id= "to" name="to" onfocus="datePicker();"/>
我很感激任何帮助