我有一个功能可以隐藏星期拣选者的日子。除此之外,还需要隐藏具体的日子...... 例如:“09/09/2014”,“10/10/2014”
这是我的jquery ......
jQuery("#wpsc_checkout_form_9998").datepicker(
"option",
"beforeShowDay",
function(date) {
var day = date.getDay();
return [(day != 4) && (day != 2), ''];
}
);
答案 0 :(得分:2)
创建要排除的日期数组,并在beforeShowDay
选项中添加对它们的检查:
$(document).ready(function () {
var arrDisabledDates = {};
arrDisabledDates[new Date('08/08/2014')] = new Date('08/08/2014');
arrDisabledDates[new Date('08/30/2014')] = new Date('08/30/2014');
$('#txtDate').datepicker({
beforeShowDay: function (date) {
var day = date.getDay(),
bDisable = arrDisabledDates[date];
if (bDisable) return [false, '', '']
else return [(day != 4) && (day != 2)];
}
});
});
在此处查找演示:jQuery Datepicker excluding specific dates and days
这是我在此处找到的特定日期的示例的调整版本:http://www.jquerybyexample.net/2013/03/hide-disable-dates-in-jquery-ui-datepicker.html