在datepicker中打开两个月

时间:2017-04-16 21:08:39

标签: jquery twitter-bootstrap datepicker

我正在使用bootstrap datepicker。我想在一个输入中打开两个月。当月和下个月。

以下是一些网页:

https://www.kayak.de/flights

https://www.turna.com/

<input class="form-control date-picker-start" placeholder="Başlangıç Tarihi" type="text">

$('.date-picker-start').datepicker({
                format: 'dd.mm.yyyy',
                autoclose : true
            }).on('changeDate',function(e){
                //on change of date on start datepicker, set end datepicker's date
                $('.date-picker-end').datepicker('setStartDate',e.date)
            });

我是否在bootstrap-datepicker中使用了任何参数。

1 个答案:

答案 0 :(得分:1)

这可以通过设置numberOfMonths

来完成

$('.date-picker-start').datepicker({
    format: 'dd.mm.yyyy',
    numberOfMonths: 2,
    autoclose : true
}).on('changeDate',function(e){
    //on change of date on start datepicker, set end datepicker's date
    $('.date-picker-end').datepicker('setStartDate',e.date)
});
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css"><script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>

<input class="date-picker-start" data-provide="datepicker">