我正在使用jquery ui datepicker(范围),如果我向下滚动页面则单击以打开日期选择器后日历消失了。
有人遇到这个问题吗?
你能检查我的代码吗?
function datePicker(){
$( function() {
var dateFormat = "mm/dd/yy",
from = $( "#checkin,.checkin" )
.datepicker({
numberOfMonths: 2,
firstDay: 1,
minDate: 0,
beforeShow:function(){
$(this).datepicker("widget").addClass("main-datepicker");
}
})
.on( "change", function() {
to.datepicker( "option", "minDate", getDate( this ) );
}),
to = $( "#checkout,.checkout" ).datepicker({
numberOfMonths: 2,
firstDay: 1,
minDate: 0,
beforeShow:function(){
$(this).datepicker("widget").addClass("main-datepicker");
}
})
.on( "change", function() {
from.datepicker( "option", "maxDate", getDate( this ) );
});
function getDate( element ) {
var date;
try {
date = $.datepicker.parseDate( dateFormat, element.value );
} catch( error ) {
date = null;
}
return date;
}
} );
}
datePicker();
<link href="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css" rel="stylesheet"/>
From : <input type="text" class="checkin">
To: <input type="text" class="checkout">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
最佳答案
从更改代码行
<link href="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css" rel="stylesheet"/>
至
<link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css" rel="stylesheet"/>
关于jquery - Datepicker在 Safari 中消失了,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46113281/