Опитвам се да използвам Jquery datepicker с база данни MySQL, за да покажа всякакви дати, които имат събития.
Настроих showOtherMonths: вярно заради предпочитанията.
Това, което бих искал да направя, е да оформям дати с увреждания, които са в текущия месец, така че да не са със същия цвят като датите през останалите месеци.
как мога да добавя стиловете за това?
$(document).ready(function()
{
var selected_dates = new Array();
// get all the events from the database using AJAX
selected_dates = getSelectedDates();
$("#datepicker").datepicker({
dateFormat: "yy-m-d",
inline: true,
showOtherMonths: true,
dayNamesMin: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
beforeShowDay: function (date)
{
// get the current month, day and year
// attention: the months count start from 0 that"s why you"ll need +1 to get the month right
var mm = date.getMonth() + 1,
dd = date.getDate(),
yy = date.getFullYear();
var dt = yy + "-" + mm + "-" + dd;
if(typeof selected_dates[dt] != "undefined")
{
// put a special class to the dates you have events for so you can distinguish it from other ones
// the "true" parameter is used so we know what are the dates that are clickable
return [true, " my_class"];
}
return [false, ""];
}
});
});
Отговори:
1 за отговор № 1Можете да използвате css def
.ui-datepicker-other-month.ui-state-disabled:not(.my_class) span{
color: red;
}
Демонстрация: цигулка