如何使用 Jquery Datepicker 在 beforeeshowday 中突出显示两种不同类型的特殊日期?

发布于 2024-08-07 05:24:38 字数 428 浏览 4 评论 0原文

我的意思是,我发现 这里有一种禁用国庆节数组的方法。

我正在尝试编写一个代码来禁用国庆日,并突出显示其他一些日子(我正在编写一个网络应用程序,我将通过另一天的数组),但让它们启用。

想象一个日历,您可以看到三种不同的日期颜色。第一个,今天的约会。第二个,灰残国庆节。在第三种颜色中,不同的日子会发生一些特别的事情。

这可能吗?

另外,我在哪里可以找到 datepicker ui 中的 css 代码来更改默认日期和禁用的日期 css 属性。

提前致谢。

I mean, I found here a way to disable an array of nationalDays.

I'm trying to make a code to disable the national days and also to highlight some other days (I'm coding a web app and I will pass another array of days) but to let them enabled.

Imagine a calendar where you can see three different day colors. The first one, today's date. The second, greyed disabled national days. And in a third color, different days where something special will happen.

Is this possible.

Also, where can i find the css codes in datepicker ui to change the default date, and the disabled date css properties.

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半透明的墙 2024-08-14 05:24:38

根据您链接到的页面的功能:

$(".selector").datepicker({ beforeShowDay: specialAndNationalDays});

natDays = [
  [1, 26, 'au'], [2, 6, 'nz'], [3, 17, 'ie'],
  [4, 27, 'za'], [5, 25, 'ar'], [6, 6, 'se'],
  [7, 4, 'us'], [8, 17, 'id'], [9, 7, 'br'],
  [10, 1, 'cn'], [11, 22, 'lb'], [12, 12, 'ke']
];
speDays = [
  [1, 10, 'mbd'], // Moms Bday
  [7, 20, 'dbd']  // Dads Bday
];

function nationalDays(date) {
    for (i = 0; i < natDays.length; i++) {
      if (date.getMonth() == natDays[i][0] - 1
          && date.getDate() == natDays[i][1]) {
        return [false, natDays[i][2] + '_day'];
      }
    }
  return [true, ''];
}
function specialAndNationalDays(date) {
    for (i = 0; i < speDays.length; i++) {
      if (date.getMonth() == speDays[i][0] - 1
          && date.getDate() == speDays[i][1]) {
        return [true, speDays[i][2] + '_day']; 
        // first variable in return enables(true)/disables(false) the date
      }
    }
  return nationalDays(date);
}

Based on the function from the page you linked to:

$(".selector").datepicker({ beforeShowDay: specialAndNationalDays});

natDays = [
  [1, 26, 'au'], [2, 6, 'nz'], [3, 17, 'ie'],
  [4, 27, 'za'], [5, 25, 'ar'], [6, 6, 'se'],
  [7, 4, 'us'], [8, 17, 'id'], [9, 7, 'br'],
  [10, 1, 'cn'], [11, 22, 'lb'], [12, 12, 'ke']
];
speDays = [
  [1, 10, 'mbd'], // Moms Bday
  [7, 20, 'dbd']  // Dads Bday
];

function nationalDays(date) {
    for (i = 0; i < natDays.length; i++) {
      if (date.getMonth() == natDays[i][0] - 1
          && date.getDate() == natDays[i][1]) {
        return [false, natDays[i][2] + '_day'];
      }
    }
  return [true, ''];
}
function specialAndNationalDays(date) {
    for (i = 0; i < speDays.length; i++) {
      if (date.getMonth() == speDays[i][0] - 1
          && date.getDate() == speDays[i][1]) {
        return [true, speDays[i][2] + '_day']; 
        // first variable in return enables(true)/disables(false) the date
      }
    }
  return nationalDays(date);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文