简体   繁体   English

如果在日历中不起作用,则 getDay javascript

[英]getDay javascript if not work in calendar

But do not work please help I just want to tell if today is Sunday adding the class calDisable但是不工作请帮助我只想知道今天是否是星期天添加类calDisable

This source这个来源

https://github.com/Thibor/jsRapCalendar https://github.com/Thibor/jsRapCalendar

in this code I want to cancel on Sunday在这段代码中,我想在周日取消

i try in我试试

this.week = this.opt.date.getDay();


    if(this.week == 4)
        d.addClass('calDisable');

the getDay() method is zero-indexed, and Sunday is the first day of the week, so you need to run whatever code you need when this.week === 0 getDay()方法是零索引的,而星期日是一周的第一天,所以你需要在this.week === 0时运行你需要的任何代码

  • 0 = Sunday 0 = 星期日
  • 1 = Monday 1 = 星期一
  • 2 = Tuesday 2 = 星期二
  • 3 = Wednesday 3 = 星期三
  • 4 = Thursday 4 = 星期四
  • 5 = Friday 5 = 星期五
  • 6 = Saturday 6 = 星期六

this.week = this.opt.date.getDay(); if(this.week === 0) d.addClass('calDisable');

This should work.这应该有效。 Not sure why are you comparing to 4 since 4 represents Thursday.不知道您为什么要与 4 进行比较,因为 4 代表星期四。

The value returned by the Javascript getDay() method is an integer corresponding to the day of the week. Javascript getDay() 方法返回的值是一个与星期几对应的整数。 It will be 0 for Sunday, 1 for Monday, ..... , 5 for Friday and 6 for Saturday.周日为 0,周一为 1,......,周五为 5,周六为 6。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM