Highlight dates in specific range with jQuery's datepicker

后端 未结 7 1353
余生分开走
余生分开走 2020-11-27 19:06

I need to highlight the dates between a start date and an end date, which I should be able to specify. Can anyone help me?

相关标签:
7条回答
  • 2020-11-27 19:55

    mugur, your code didn't quite work for me in Firefox or Safari, it required the date var to be formatted (which I got from here). Here

    function highlightDays(date) {
    for (var i = 0; i < dates.length; i++) {
    
    var d = date.getDate();
    var m =  date.getMonth();
    m += 1;  // JavaScript months are 0-11
    var y = date.getFullYear();
    
    var dateToCheck = (d + "/" + m + "/" + y);
        if (dates[i] == dateToCheck) {
            return [true, 'highlight', tips[i]];
        }
        }
    return [true, ''];
    }
    

    And, of course, as the above function stands it doesn't account for leading-zeroes padding so the dates array needed to be changed to:

    var dates = ['22/1/2014', '23/1/2014'];
    
    0 讨论(0)
提交回复
热议问题