var holiDays =[[2018,10,23,'New Years Day'],[2018,10,24,'Pongal'],[2018,10,25,'Christmas Day']];
$('#calendar').datepicker({
beforeShowDay: setHoliDays,
onSelect: function (date) {
alert();
}
});
我可以从setHolidays
中的函数alert()
的结果中触发title属性吗?
function setHoliDays(date) {
for (i = 0; i < holiDays.length; i++) {
if (date.getFullYear() == holiDays[i][0]
&& date.getMonth() == holiDays[i][1] - 1
&& date.getDate() == holiDays[i][2]) {
return [true, 'holiday', holiDays[i][3]];
}
}
return [true, ''];
}
答案 0 :(得分:0)
我想你想要这样的东西。
Program received signal SIGSEGV, Segmentation fault.
0x000000000040072a in addCarinfo (carbase=0x602010, newcar=0x602080)
at database.c:56
56 tempcar2 = tempcar2->next;
(gdb) bt
#0 0x000000000040072a in addCarinfo (carbase=0x602010, newcar=0x602080)
at database.c:56
#1 0x0000000000400869 in main () at database.c:98
var holiDays =[[2018,10,23,'New Years Day'],[2018,10,24,'Pongal'],[2018,10,25,'Christmas Day']];
$('#calendar').datepicker({
beforeShowDay: setHoliDays,
onSelect: function (date) {
getTitle(date)
}
});
function setHoliDays(date) {
for (i = 0; i < holiDays.length; i++) {
if (date.getFullYear() == holiDays[i][0]
&& date.getMonth() == holiDays[i][1] - 1
&& date.getDate() == holiDays[i][2]) {
return [true, 'holiday', holiDays[i][3]];
}
}
return [true, ''];
}
function getTitle(date){
var date=new Date(date);
for (i = 0; i < holiDays.length; i++) {
if (date.getFullYear() == holiDays[i][0]
&& date.getMonth() == holiDays[i][1] - 1
&& date.getDate() == holiDays[i][2]) {
alert(holiDays[i][3]);
}
}
}
.holiday{
background:red;
}
.holiday a{
background: red !important;
color: white !important;
}