1

我正在使用 jQuery UI 来显示 2 个月的内联日期选择器,我想启用从一天到另一天的范围选择,并在其间突出显示,并用一些“捕捉”开始日期今天日期回调,所以我可以将它们插入到一些输入中。

这是我当前的代码:

HTML:

 <div id="journey-calendar"></div>

脚本:

    $('#journey-calendar').datepicker({
        numberOfMonths: [2, 1],
        showOtherMonths: true,
        altField: '.begin-trip-date',
        altFormat: 'dd M yy', defaultDate: null
    });

我将不胜感激任何帮助或演示!

4

1 回答 1

0

I did something similar to this. I had 2 datepickers, one for a start date and one for an end date. I added a css class to set a background color for the dates in the range. Here is my code:

},
beforeShowDay: function(date) {
  var fromDate = new Date($(".lblDateFrom").text());
  var toDate = new Date($(".lblDateTo").text());     

  if (date >= fromDate && date <= toDate) {
    return [true, 'ui-individual-date', ''];
  }
  else {
    return [true, '', ''];
 }
},

//css class
.ui-individual-date {
background-color: #F2F5F7;
}
于 2015-04-03T15:29:27.573 回答