我有一些使用 flatpickr 日历实例的 HTML。我想做的是在单击随附的跨度时仅打开特定的日历实例。
<div class="formRow">
<div class="datetimepicker input-group date">
<input id="initial-notification-date-time" name="initial-notification-date-time" type="text" class="form-control" />
<span class="input-group-addon"></span>
</div>
</div>
随附的 Javascript 是:
$('.datetimepicker input').flatpickr({
dateFormat: 'm/d/Y',
enableTime: true,
defaultDate: new Date(),
onReady: function() {
var flatPickrInstance = this;
console.log(flatPickrInstance);
console.log($(".datetimepicker input").siblings(".datetimepicker span"));
$(".datetimepicker input").siblings(".datetimepicker span").click(function () {
$(".datetimepicker input").flatpickr();
});
}
});
当前所做的是导致“.datetimepicker input”的所有实例重新初始化为新实例。我实际上如何导致我想要打开的实例?