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

カレンダーに月と年のみを表示するには、次の 2 つの方法があります。

<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 に答える