这是我的代码
onSelect: function (dateText, inst)
{
inst.inline = false;
$(".ui-datepicker-current-day").addClass("markupDate");
}
当我检查 html 代码时,“markupDate”类已成功添加到 html 元素中。
我选择另一个日期,如果日期已经有一个“markupDate”类,我用我的 onSelect 函数检查。如果没有,我添加它。
问题是,当我点击一个已经有“markupDate”类的日期并且我用jquery询问单元格是否有“markupDate”类时,结果是错误的。
但是当检查 chrome 中的元素时, $(".ui-datepicker-current-day") 已经有类 "markupDate" !
这是代码
onSelect: function (dateText, inst)
{
//no markupDate class in the result !
console.log(($(".ui-datepicker-current-day").attr("class")));
inst.inline = false;
/*result is ever false !*/
if($(".ui-datepicker-current-day").hasClass("markupDate")){
//do something
}else{
$(".ui-datepicker-current-day").addClass("markupDate");
}
}
jquery-ui 库中 _selectDay 的代码是
_selectDay: function (a, b, c, d) {
var e = $(a);
if ($(d).hasClass(this._unselectableClass)
|| this._isDisabledDatepicker(e[0]))
return;
/*i put my code here and i return =>my code is working */
var f = this._getInst(e[0]);
f.selectedDay = f.currentDay = $("a",d).html(), f.selectedMonth =
f.currentMonth = b, f.selectedYear =f.currentYear = c,
this._selectDate(a, this._formatDate(f, f.currentDay, f.currentMonth,
f.currentYear))
当我直接在里面添加我的代码时,我在这一行之前返回:
var f = this._getInst(e[0]);
onSelect 函数检索 $(".ui-datepicker-current-day") 是否具有类“markupDate”。
谢谢你的帮助。