如何在引导日期选择器中突出显示特定日期? [英] How to highlight specific dates in bootstrap datepicker?

查看:69
本文介绍了如何在引导日期选择器中突出显示特定日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用引导日期选择器.我需要突出显示一些随机日期.

I am using bootstrap datepicker.I need to highlight some random dates.

例如:

我需要突出显示日期,例如1,3,8,20,21,16,26,30.您能告诉我如何在引导日期选择器中突出显示那些随机日期吗?

I need to highlight the dates like 1,3,8,20,21,16,26,30. Could you please tell me how to highlight those random dates in bootstrap datepicker?

推荐答案

如amphetamachine所建议在bootstrap-datepicker上突出显示某些日期提供了解决此问题所需的大部分方法.该问题的答案可以适应以下情况

As suggested by amphetamachine Highlight certain dates on bootstrap-datepicker provides most of what is required to solve this. The answer to that question can be adapted to the following

$('.inline_date').datepicker({
    multidate: true,
    todayHighlight: true,
    minDate: 0,
    beforeShowDay: function(date) {
       var hilightedDays = [1,3,8,20,21,16,26,30];
       if (~hilightedDays.indexOf(date.getDate())) {
          return {classes: 'highlight', tooltip: 'Title'};
       }
    }
});

以上内容将突出显示样式类应用于每月列出的日期,进一步检查您可以将其限制为特定月份.某些旧的浏览器可能不支持indexOf,在这种情况下,您可以使用JS库或扩展if.

The above will apply the highlight style class to the listed days in every month, with further checks you could limit it to specific months. Some old browsers may not support indexOf, in which case you can either use a JS library or expand the if.

这篇关于如何在引导日期选择器中突出显示特定日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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