更新时间:2023-01-29 19:51:11
$。inArray(dmy,availableDates)返回索引的元素,所以当你与1比较只有14-5-2011将匹配。检查不等于-1。应该工作。
$.inArray(dmy, availableDates) returns the index of the element, so when you compare with 1 only 14-5-2011 will match. Check for not equal to -1. Should work.
小提琴 - http:// jsfiddle。 net / yXMKC / 4 /
var availableDates = ["9-5-2011","14-5-2011","15-5-2011"];
function available(date) {
dmy = date.getDate() + "-" + (date.getMonth()+1) + "-" + date.getFullYear();
console.log(dmy+' : '+($.inArray(dmy, availableDates)));
if ($.inArray(dmy, availableDates) != -1) {
return [true, "","Available"];
} else {
return [false,"","unAvailable"];
}
}