當(dāng)從程序的日歷中選擇相關(guān)日期時(shí),我希望選擇的日期為紅色,其他非約會(huì)日期為綠色。這是一個(gè)ASP.NET MVC web應(yīng)用程序,在客戶端使用javascript和jquery。
<script>
var today = new Date();
var today_formatted = today.getFullYear() + '-' + (today.getMonth() + 1) + '-' + ('0' + today.getDate()).slice(-2);
var user_busy_days = ['2017-12-09', '2017-12-16', '2017-12-19'];
$('#datetimepicker12').datepicker({
inline: true,
sideBySide: true,
beforeShowDay: function (date) {
calender_date = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + ('0' + date.getDate()).slice(-2);
var search_index = $.inArray(calender_date, user_busy_days);
if (search_index > -1) {
return { classes: 'non-highlighted-cal-dates', tooltip: 'User available on this day.' };
} else {
return { classes: 'highlighted-cal-dates', tooltip: 'User not available on this day.' };
}
}
});
$( document ).ready(function() {
$(function () {
var array = [];
$.get('@Url.Action("Kontrol", "Randevu")').done(function (data) {
if (data!="") {
array.push(data);
console.log(array);
console.log(data);
}
})
var dateToday = new Date();
$("#TxtBasTar").datepicker({
monthNames: ["Ocak", "?ubat", "Mart", "Nisan", "May?s", "Haziran", "Temmuz", "A?ustos", "Eylül", "Ekim", "Kas?m", "Aral?k"],
dayNamesMin: ["Pa", "Pt", "Sl", "?a", "Pe", "Cu", "Ct"],
dateFormat: 'dd.mm.yy',
beforeShowDay: function (date) {
var day = date.getDay();
var string = jQuery.datepicker.formatDate('d.m.yy', date);
console.log(string);
if (day == 0)
return ['',"markholiday"];
else
return [array.indexOf(string) == -1]
},
minDate: dateToday,
});
// $('#datetimepicker').on('dp.show', function (e) {
// highlight()
// })
// $('#datetimepicker').on('dp.update', function (e) {
// highlight()
// })
// $('#datetimepicker').on('dp.change', function (e) {
// highlight()
// })
// function highlight() {
// var dateToHilight = ["04/19/2019", "04/20/2019", "04/30/2019"];
// var array = $("#datetimepicker").find(".day").toArray();
// for (var i = 0; i - 1) {
// array[i].style.color = "#090";
// array[i].style.fontWeight = "bold";
// }
// }
//}
});
});
</script>
我已經(jīng)創(chuàng)建了一個(gè)這樣的日期選擇器函數(shù),如何添加或更改著色操作?