如何突出显示datepicker中的特定日期

时间:2012-10-24 15:38:11

标签: javascript jquery datepicker

如何突出显示datepicker中BOLD个特定日期?我有一个日期var datesArray = new Array();的数组我知道我需要使用beforeShowDay:方法,但我无法弄清楚它是否有效。

这是我的功能:

            $(function() {
                $( "#datepicker" ).datepicker({ 
                    dateFormat: 'yy-mm-dd', 
                    onSelect: function(dateText, inst) {                             
                        dateSelected(dateText, tid) // run my function on click
                    }                     
                });
            });

1 个答案:

答案 0 :(得分:1)

是的,您需要使用beforeShowDay事件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'];
    }
    ...
相关问题