隐藏jQuery Datepicker的工作日和特定日期 [英] Hide weekdays and specific dates of jquery datepicker
本文介绍了隐藏jQuery Datepicker的工作日和特定日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个隐藏星期几日期选择器的功能.除此以外,还需要隐藏特定的日子... 例如:"09/09/2014","10/10/2014"
I have a function that hides the days of the weeks datepicker. Need, in addition to this, hide specific days ... Ex: "09/09/2014", "10/10/2014"
这是我的jquery ...
This is my jquery ...
jQuery("#wpsc_checkout_form_9998").datepicker(
"option",
"beforeShowDay",
function(date) {
var day = date.getDay();
return [(day != 4) && (day != 2), ''];
}
);
推荐答案
创建要排除的日期的数组,并在beforeShowDay
选项中添加对它们的检查:
Create an array of the days you want to exclude and add checking for them in the beforeShowDay
option:
$(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,不包括特定日期和日期
This is an adjusted version of an example for excluding specific dates I just found here: http://www.jquerybyexample.net/2013/03/hide-disable-dates-in-jquery-ui-datepicker.html
这篇关于隐藏jQuery Datepicker的工作日和特定日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文