使用jquery datepicker ui排除大量日期的最佳方法是什么?我是jquery的新手,所以如果你能详细说明,那将特别有用。
要包括的日期范围很大...... 100年。要排除的日期很多而且不是连续的。所以范围看起来像这样:
此外,我需要在选择时显示每个日期以显示相应的图像。每个日期都有一个独特的图像。有人告诉我使用.attr()方法。有谁知道一个例子?
$(function(){
/* create an array of days which need to be disabled */
var disabledDays = ["1-14-1962","2-11-1962","3-22-1963","4-1-1963","6-9-1964","7-17-1964","8-9-65", "1-2-66","4-1-66","8-3-67", "7-22-2011", "2-21-2010", "2-24-2010", "2-27-2010","2-28-2010", "3-3-2010","3-17-2010","4-2-2010", "4-3-2010","4-4-2010","4-5-2010", "7-22-2011"];
// Datepicker
$('#datepicker').datepicker({
inline: true,
dateFormat: 'yy-mm-dd', //Month & Day spelled out
constrainInput: true,
changeMonth: true,
changeYear: true,
maxDate: '0',
yearRange: '-102y', //Going back to 1910
onSelect: function(dateText, inst) {
window.location = 'http://www.example.com' + dateText;
}
});
});
<code>