0

我是编程新手,只想知道如何使用 jQuery multipleDatesPicker 选择多个月份。只是月份和年份。

源代码。

$(function() {
   $('.date-picker').multiDatesPicker( {
      changeMonth: true,
      changeYear: true,
      showButtonPanel: true,
      dateFormat: "yy-mm",
      onClose: function(dateText, inst) { 
         var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
         var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
         debugger;
         $(this).multiDatesPicker('setDate', new Date(year,month,1));
     }
   });
});

CSS:

.ui-datepicker-calendar {
  display: none;
}
4

1 回答 1

0

您可以做两件事来在日历中只显示月份和年份:

<style>
.ui-datepicker-calendar {
    display: none;
}
</style>

$('.date-picker').multidatespicker( {
    changeMonth: true,
    changeYear: true,
    showButtonPanel: true,
    dateFormat: 'MM yy',
    onClose: function(dateText, inst) { 
        $(this).multidatespicker('setDate', new Date(inst.selectedYear, inst.selectedMonth, 1));
    }
});
于 2016-11-21T20:52:36.140 回答