本文介绍了如何突出显示datepicker中的具体日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在 BOLD
中突出显示日期标记中的特定日期?我有数组包含日期 var datesArray = new Array();
我知道我需要使用 beforeShowDay:
方法,但是我无法确定它是否正常工作。
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.
这是我的功能:
$(function() {
$( "#datepicker" ).datepicker({
dateFormat: 'yy-mm-dd',
onSelect: function(dateText, inst) {
dateSelected(dateText, tid) // run my function on click
}
});
});
推荐答案
是的,您需要使用beforeShowDay事件,
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'];
}
...
这篇关于如何突出显示datepicker中的具体日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!