twitter-bootstrap Onclick 日关闭引导程序日期选择器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21898630/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 20:06:26  来源:igfitidea点击:

Onclick day close bootstrap datepicker

javascriptjquerytwitter-bootstrapdatepicker

提问by Hassan Sardar

I want to close datepicker when click on day. How is this possible in Bootstrap Datepicker?

我想在点击日期时关闭日期选择器。这在 Bootstrap Datepicker 中怎么可能?

Here is the fiddle:

这是小提琴:

http://jsfiddle.net/kGGCZ/17/

http://jsfiddle.net/kGGCZ/17/

$('#dob').datepicker(
{
    endDate:ageDate
}
);

回答by Bharat soni

You the auto-close property of the bootstrap date-piker like below

你像下面这样的引导日期选择器的自动关闭属性

$('#dob').datepicker(
{
    endDate:ageDate,
    autoclose: true
}
);

I have already updated your js-fiddle

我已经更新了你的 js-fiddle

Updated fiddle

更新的小提琴

回答by contactmatt

Note that if you are using Stefan Petre's original version of the Bootstrap Datepicker, the autoclose property will [as of this writing] not work. In this case, you should do something like this:

请注意,如果您使用的是 Stefan Petre 的Bootstrap Datepicker原始版本,则 autoclose 属性 [在撰写本文时] 将不起作用。在这种情况下,您应该执行以下操作:

$('#myDate').datepicker().on('changeDate', function (e) {
    $('#myDate').datepicker('hide');
});

If you're using eternicode's forked version, the autoclose property will work.

如果您使用的是 eternicode 的分叉版本,则 autoclose 属性将起作用。

回答by chriz

initialize your date picker with option 'autoclose'

使用选项“自动关闭”初始化您的日期选择器

$('#dob').datepicker(
{"autoclose": true});

or you can close date picker by using following code also

或者您也可以使用以下代码关闭日期选择器

$('#dob').datepicker().on('changeDate', function (ev) {
    $('#dob').hide();
    });

回答by dfortun

$('#Date3').datepicker({
        format: "mm-yyyy",
        viewMode: "months",
        minViewMode: "months"
    }).on('changeDate', function (e) {
        $('#Date3').datepicker('hide');
    });