我试图隐藏内联日期选择器,当点击其他地方而不是datepicker时,但当点击 nextMontButton 和 previousMonthButton
时它也会消失有什么想法吗?
<div id="all">
<div id="datepicker"> </div> //here is datpicker
<div id="submitDiv"> //here is submit in datepicker style
<input type="submit" name="day" value="Done" id="datePickerSubmit">
<input type="hidden" id="date" name="date" value="">
</div>
</div>
jQuery(document).ready(function(){
jQuery('#datepicker').datepicker({
firstDay: 1,
minDate: +2,
maxDate: "+1m",
dateFormat: "yy-mm-dd",
inline: true,
altField: '#date'
});
})
// HIDES DATETIME PICKER WHEN CKICK SOMEWHERE ELSE
$(document).click(function(e) {
var target = e.target;
if (!$(target).is('#all') && !$(target).parents().is('#all'))) {
document.querySelector("#datepicker").style.display = "none";
document.querySelector("#submitDiv").style.display = "none";
}
});