gpt4 book ai didi

javascript - daterangepicker 只显示年份和月份

转载 作者:数据小太阳 更新时间:2023-10-29 05:15:15 27 4
gpt4 key购买 nike

我正在使用 daterangepicker bootstrap 3。

$('#pa_date*').daterangepicker({
singleDatePicker: true,
showDropdowns: true,
minDate: min,
maxDate: max,
format: 'DD/MM/YYYY'
}).on('apply.daterangepicker', function (ev, picker) {
alert(picker.startDate.format('MM/YYYY'));
});

它向我展示了完整的日期范围选择器:

enter image description here

我想隐藏日历并只显示年份和月份的下拉列表,如下所示:

enter image description here

最佳答案

只需添加以下 css ...

$('input[name="daterange"]').daterangepicker({
singleDatePicker: true,
showDropdowns: true,
minDate: '06/01/2013',
maxDate: '06/30/2015',
format: 'DD/MM/YYYY'
}).on('hide.daterangepicker', function (ev, picker) {
$('.table-condensed tbody tr:nth-child(2) td').click();
alert(picker.startDate.format('MM/YYYY'));
});
.table-condensed thead tr:nth-child(2),
.table-condensed tbody {
display: none
}
<script src="https://code.jquery.com/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script type="text/javascript" src="//cdn.jsdelivr.net/momentjs/2.9.0/moment.min.js"></script>
<script type="text/javascript" src="//cdn.jsdelivr.net/bootstrap.daterangepicker/1/daterangepicker.js"></script>
<link rel="stylesheet" type="text/css" href="//cdn.jsdelivr.net/bootstrap.daterangepicker/1/daterangepicker-bs3.css" />

<input name="daterange" value="DD/MM/YYYY">

关于javascript - daterangepicker 只显示年份和月份,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30618462/

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