0

在我的应用程序中尝试使用pickadate datepicker日历,是否可以仅显示月份和年份的日历?

$('#datePicker').pickadate({
      selectMonths: true, // Creates a dropdown to control month
      selectYears: 150, // Creates a dropdown of 15 years to control year
      format: 'mmm-yyyy',
      max: true,
      onSet: function (arg) {
        if ('select' in arg) { //prevent closing on selecting month/year
          this.close();
        }
      }
    });
4

2 回答 2

1
var from_$input = $('.from_date').pickadate({
    today: 'Ok',
    format: 'mmmm-yyyy',
    min: new Date(),
    formatSubmit: 'yyyy-mm-dd',
    hiddenPrefix: 'prefix__',
    hiddenSuffix: '__suffix',
    selectYears: true,
    selectMonths: true,
  }),
于 2020-09-09T08:55:43.040 回答
0
var nowTemp = new Date();
var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), 0, 0, 0, 0, 0);

var checkin = $('#dpd1').datepicker({
  onRender: function(date) {
    return date.valueOf() < now.valueOf() ? 'disabled' : '';
  }
}).on('changeDate', function(ev) {
  if (ev.date.valueOf() > checkout.date.valueOf()) {
    var newDate = new Date(ev.date)
    newDate.setDate(newDate.getDate() + 1);
    checkout.setValue(newDate);
  }
  checkin.hide();
  $('#dpd2')[0].focus();
}).data('datepicker');
var checkout = $('#dpd2').datepicker({
  onRender: function(date) {
    return date.valueOf() <= checkin.date.valueOf() ? 'disabled' : '';
  }
}).on('changeDate', function(ev) {
  checkout.hide();
}).data('datepicker');
于 2016-06-05T10:15:01.223 回答