gpt4 book ai didi

javascript - 如何在选择日期后关闭日期时间选择器?

转载 作者:行者123 更新时间:2023-12-03 07:15:12 27 4
gpt4 key购买 nike

我正在使用datetimepicker

选择日期值后,我不知道如何关闭小部件。

我的代码:

    $(settings.target).datetimepicker({
useCurrent: "hour",
minDate: settings.minDate,
maxDate: settings.maxDate,
keepOpen : false,
locale: settings.locale
});

$(settings.target).on("dp.change", function (e) {
$(settings.target).trigger("dp.hide");
})

$(settings.target + " .action").on("focus", function (e) {
$(this).next().trigger("click");
})

HTML:

                    <div class="row filterRes">
<div class='col-sm-6'>
<div class="form-group">
<div class='input-group date' id='datetimepickerFrom'>
<input type='text' class="form-control action" placeholder="Från" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
<div class='col-md-6'>
<div class="form-group">
<div class='input-group date' id='datetimepickerTo'>
<input type='text' class="form-control action" placeholder="Till" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
</div>

尝试了其他几次尝试,但无法弄清楚。我该怎么做?

最佳答案

这对我来说非常有用......当用户单击字段时,小部件会显示,当选择日期时它会消失......

仅供引用,页面开头有一条注释:

Note All functions are accessed via the data attribute e.g. $('#datetimepicker').data("DateTimePicker").FUNCTION()

$(settings.target).on("dp.change", function (e) {
$(this).data("DateTimePicker").hide();
});

$(settings.target).on("click", function (e) {
$(this).data("DateTimePicker").show();
});

祝你好运...

关于javascript - 如何在选择日期后关闭日期时间选择器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36456479/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com