我正在尝试在某些禁用日期上添加工具提示作为假期原因,但在悬停时无法显示它们。我什至尝试添加自定义悬停功能,但没有成功。
availableDates = ["09/04/2018", "09/05/2018", "09/06/2018", "08/31/2018", "09/01/2018"];
holidays_dates = { "09/02/2018": "sgsdf", "05/27/2018": "home sick", "08/20/2018": "fcg", "05/26/2018": "i dont know", "05/25/2018": "home sick" }
function available(date) {
var moth = String(date.getMonth() + 1);
if (moth.length == 1) {
moth = "0" + moth;
}
var dat = String(date.getDate());
if (dat.length == 1) {
dat = "0" + dat;
}
dmy = moth + "/" + dat + "/" + date.getFullYear();
if ($.inArray(dmy, availableDates) != -1) {
return [true, ""];
} else if (dmy in holidays_dates) {
console.log(dmy)
return [false, "Highlighted", holidays_dates[dmy]];
} else {
return [false, ""];
}
}
$("#datepicker").datepicker({
beforeShowDay: function (dt) {
return available(dt);
},
changeMonth: true,
changeYear: true,
onSelect: function (dateText) {
getslots(dateText, selected_consultant);
}
});
Holiday_dates 变量由禁用日期和原因组成,并且完美地将原因添加到元素的标题中
<td class=" ui-datepicker-unselectable ui-state-disabled Highlighted" title="home sick">
<span class="ui-state-default">25</span>
</td>
如上所述,在标签的标题属性中添加了假期原因,但悬停在该日期不显示工具提示