问题
i have this function that highlights the given dates and hide the others(not actually hide but undetectable).
var availableDates = ['1-12-2017','5-12-2017'];
function availableFunction(date) {
availday = date.getDate() + "-" + (date.getMonth()+1) + "-" + date.getFullYear();
if (jQuery.inArray(availday, availableDates) > -1) {
return [true,"eventday",""];
} else {
return [true,"ui-datepicker-unselectable ui-state-disabled ",""];
}
}
Now i am gettings dates from database by jquery and pass to the above function.
var t_date = jQuery('.date-<?php echo $post->ID?>').html();
var availableDates = [t_date];
code still working fine but i want to get multiple dates and highlights them. so i use this code.
var tttdates = document.getElementsByName("tttdate<?php echo $post->ID?>");
var vals=[];
for (var i=0, n=tttdates.length; i<n; i++) {
vals.push(tttdates[i].textContent);
}
alert(vals.join(","));
problem is that.
var availableDates = [vals.join(",")];
i am not getting any dates highlighted. why is that?
来源:https://stackoverflow.com/questions/41485505/setting-dates-to-highlight-booked-dates-in-calendar-of-datepicker