本文介绍了禁用天数jQuery的日期选择器的阵列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是code,我一直在努力:
This is the code that i have been working upon:
$("#datepicker").datepicker({
beforeShowDay: function (day) {
for (var q = 0; q < final_array.length; q++) {
if (final_array[q] == 1 || final_array[q] == 2 || final_array[q] == 3 || final_array[q] == 4 || final_array[q] == 5 || final_array[q] == 6) {
return [false, ''];
} else {
return [true, ''];
}
}
}
});
我final_array看起来像这样[2,3,4,5]我想禁用星期二,星期三,星期五和星期六。当我运行这个code我没有得到任何输出。连错误也。谁能帮助。谢谢。
my final_array looks like this "[2, 3, 4, 5]" i want to disable Tuesdays, Wednesdays, Fridays and Saturdays. When I run this code i am not getting any output. Not even errors also. can anyone help. Thanks.
推荐答案
尝试使用过滤天 $。inArray()
var final_array = [2,3,5,6];
$("#datepicker").datepicker({
beforeShowDay: function(date) {
var day = date.getDay();
return [$.inArray(day, final_array) == -1]
}
});
Fiddle
此外, [2,3,4,5]
将意味着星期二,星期三,星期四和星期五,而不是的我要禁用星期二,星期三,星期五和周六的如你所说。使用 [2,3,5,6]
来代替。
Also, [2,3,4,5]
would mean Tuesdays, Wednesdays, Thursdays and Fridays and not i want to disable Tuesdays, Wednesdays, Fridays and Saturdays as you said. Use [2,3,5,6]
instead.
这篇关于禁用天数jQuery的日期选择器的阵列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!