我正在尝试使用jquery获取选择值,但在调试时。它只显示第一个值== 1。
知道为什么吗?这是我的代码。
var clinic = $("#AppointmentClinicId").val();
$("#datepicker").datepicker({
dateFormat: "yy-mm-dd",
minDate: 0,
numberOfMonths: 3,
showButtonPanel: true,
beforeShowDay: function(date) {
var day = date.getDay();
console.log("clinic:" + clinic);
if (clinic == 1) {
return [day == 1, ""];
}
if (clinic == 2) {
return [day == 2, ""];
}
if (clinic == 3) {
return [day == 3, ""];
}
if (clinic == 4) {
return [day == 4, ""];
}
if (clinic == 5) {
return [day == 5, ""];
}
if (clinic == 6) {
return [day == 6, ""];
}
}
}).val()
基本上,我只想根据诊所返回特定的开放日。问题是,我无法从#AppointmentClinicId获得当前值。
帮助!
答案 0 :(得分:1)
您没有阅读AppointmentClinicId的最新值。你应该每次都从dom读。
在clinic = $("#AppointmentClinicId").val();
beforeShowDay
....
beforeShowDay: function(date) {
var day = date.getDay(),
clinic = $("#AppointmentClinicId").val();
...