问题
How to Highlight in BOLD specific dates in the datepicker? I have the array with dates var datesArray = new Array(); I know that I need to use beforeShowDay: method, but I can't figure it out to make it work.
This is my function:
$(function() {
$( "#datepicker" ).datepicker({
dateFormat: 'yy-mm-dd',
onSelect: function(dateText, inst) {
dateSelected(dateText, tid) // run my function on click
}
});
});
回答1:
Yes you need to use beforeShowDay event, here is the test
...
beforeShowDay: function(d_date){
console.log(d_date);
//Here compare your Date Array and the d_date
var d_picker = new Date(d_date);
var s_class_highligth = '';
if($.inArray(d_picker.getDate(),a_date_array)>-1){
s_class_highligth = 'my_cell_highligth';
}
return [true, s_class_highligth, 'this is optional tooltip'];
}
...
来源:https://stackoverflow.com/questions/13052615/how-to-highlight-specific-dates-in-the-datepicker