Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript daterangepicker仅显示年份和月份_Javascript_Jquery_Twitter Bootstrap_Daterangepicker - Fatal编程技术网

Javascript daterangepicker仅显示年份和月份

Javascript daterangepicker仅显示年份和月份,javascript,jquery,twitter-bootstrap,daterangepicker,Javascript,Jquery,Twitter Bootstrap,Daterangepicker,我正在使用daterangepicker引导程序3 $('#pa_date*').daterangepicker({ singleDatePicker: true, showDropdowns: true, minDate: min, maxDate: max, format: 'DD/MM/YYYY' }).on

我正在使用daterangepicker引导程序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'));
            });
它显示了完整的daterangepicker:

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


只需添加以下css即可

$('input[name=“daterange”]”)。日期范围选择器({
singleDatePicker:是的,
决战:没错,
minDate:'06/01/2013',
maxDate:'06/30/2015',
格式:“DD/MM/YYYY”
}).on('hide.daterangepicker',函数(ev,picker){
$('.table-condensed-tbody tr:nth-child(2)td')。单击();
警报(picker.startDate.format('MM/YYYY');
});
.table压缩后的thead tr:n子项(2),
.表3-3{
显示:无
}

我对以前的答案做了一些修改,新的版本可以使用,我在网上添加了一些重要的注释


您可以在我提供的链接上查找详细信息,以获得快速帮助,但存在一些问题,当我选择年份和月份时,日期范围不更改或结果不给我提示消息无法与当前版本的daterangepicker一起使用。我目前正试图完成同样的事情,但他们似乎已经将事件侦听器移动到了“无”位置,因此单击按钮时将触发“无”。有什么想法吗?新版本似乎有点被窃听了。。。一些按钮丢失了,我无法让它触发任何类型的事件。我的建议:使用旧版本;D问题中没有角度标记。我建议您应该尝试使用组件样式使css工作()-
var td = $(instance.container).find('.table-condensed tbody tr:nth-child(3) td:first-child');
    /*
     * the setTimeout have on purpose to delay calling trigger
     * event when choosing date on third row, if you not provide
     * the timeout, it will throw error maximum callstack
     */
    setTimeout(function() {
      /*
       * on the newer version to pick some date was changed into event
       * mousedown
       */
      td.trigger('mousedown');
      /*
       * this was optional, because in my case i need send date with
       * starting day with 1 to keep backend neat
       */
      instance.setStartDate(instance.startDate.date(1));
      instance.setEndDate(instance.endDate.date(1));
      alert("this is start " + instance.startDate.format("DD MMM YYYY"));
      alert("this is end " + instance.endDate.format("DD MMM YYYY"));
    }, 1);