Highlight certain dates on bootstrap-datepicker

后端 未结 5 640
耶瑟儿~
耶瑟儿~ 2020-12-18 23:06

I\'m using the bootstrap-datepicker to check the days where my website got sales and I want to display or highlight the dates there was at least one sale. I can pass the dat

5条回答
  •  情深已故
    2020-12-18 23:28

    here is another example to highlight a range of dates:

    var inRange=false;
    $('#elementPicker').datepicker({
      beforeShowDay: function(date) {
        dateFormat = date.getUTCFullYear() + '-' + date.getUTCMonth() + '-' + date.getUTCDate();
    
        if (dateFormat == '2014-01-01') {
          inRange = true; //to highlight a range of dates
          return {classes: 'highlight', tooltip: 'Title'};
        }
        if (dateFormat == '2014-01-05') {
          if (inRange) inRange = false;  //to stop the highlight of dates ranges
          return {classes: 'highlight', tooltip: 'Title'};
        }
        if (inRange) {
          return {classes: 'highlight-range'}; //create a custom class in css with back color you want
        }
      }
    });
    

提交回复
热议问题