关于 javascript:Sunday 只在 Jquery Datepicker 上? | 珊瑚贝

Sunday only on Jquery Datepicker?


目标:只允许用户在 datpicker 日历上选择星期日。

目前我几乎完成了,除了周日工作以外的每隔一天。当我在下面的代码中使用 7 表示星期日时,整个日历都无法点击,其他任何一天都可以完美运行。

1
2
3
4
5
6
7
8
9
10
$(document).ready(function() {

    $(“#datepicker2”).datepicker({
        autoSize: true,         // automatically resize the input field
        altFormat: ‘yy-mm-dd’,  // Date Format used
        firstDay: 1, // Start with Monday
        beforeShowDay: function(date)

        { return [date.getDay() == 7,];}}); // Allow only one day a week
});

问题:我怎样才能只允许周日选择?


Date.getDay() 返回 0-6 范围内的值,而不是 1-7.

1
2
3
beforeShowDay: function(date) {
    return [date.getDay() === 0,];
}


来源:https://www.codenong.com/14900563/

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_9245.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?