隐藏/显示JQuery内联日期选择器

时间:2014-10-20 20:01:40

标签: javascript jquery datepicker

我试图隐藏内联日期选择器,当点击其他地方而不是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";
    }
});

0 个答案:

没有答案