Highlight dates in jquery UI datepicker

前端 未结 6 1987
暖寄归人
暖寄归人 2020-12-08 03:04

How i can use beforeShowDay for highlighting days in jQuery UI datepicker. I have the following date array

Array
(
    [0] => 2011-07-07
         


        
6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-08 03:54

    Found the most voted answer not working. Updated the code little bit to make it working. $.inArray() mostly search for indexOf(). Also we can't compare two dates directly for equality. Reference : Compare two dates with JavaScript

    function inArrayDates(needle, haystack){
        var found = 0;
        for (var i=0, len=haystack.length;i

    And update the accepted function as

    if(inArrayDates(date, markDates) != -1) {
                return [true, 'selected-highlight', 'tooltip here'];
              } else {
                 return [true, '', ''];
              }
    

提交回复
热议问题