突出显示bootstrap-datepicker上的某些日期 [英] Highlight certain dates on bootstrap-datepicker

查看:195
本文介绍了突出显示bootstrap-datepicker上的某些日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用bootstrap-datepicker检查我的网站销售的日子,我想显示或突出显示至少有一次销售的日期。我可以在JSON上传递日期,然后将它们变成Javascript的数组,但我不知道如何使日期选择器获取日期并突出显示它们。

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 dates on JSON and then make them into a Javascript's array, but I don't know how to make the datepicker to fetch the dates and highlight them.

有没有办法使用bootstrap-datepicker来实现这个目的?

Is there a way with the bootstrap-datepicker to achieve this?

推荐答案

这是另一个突出显示日期范围的例子: / p>

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
    }
  }
});

这篇关于突出显示bootstrap-datepicker上的某些日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆