在jQuery UI Datepicker中设置一周的开始日期?

Rud*_*udi 44 jquery jquery-ui

我正在浏览jQuery UI Datepicker(http://jqueryui.com/demos/datepicker/)的文档,但我找不到如何将星期的第一天设置为星期一.

应用区域设置会将星期一设置为一周的第一天,但​​这也会更改语言.

Bij*_*jan 74

这是我使用的示例配置.用"firstDay:1"查看最后一行.我认为使用这样的sytax指定datepicker选项看起来更好;)

$('#datepickerfield').datepicker({
    constrainInput: true,   // prevent letters in the input field
    minDate: new Date(),    // prevent selection of date older than today
    showOn: 'button',       // Show a button next to the text-field
    autoSize: true,         // automatically resize the input field 
    altFormat: 'yy-mm-dd',  // Date Format used
    beforeShowDay: $.datepicker.noWeekends,     // Disable selection of weekends
    firstDay: 1 // Start with Monday
})
Run Code Online (Sandbox Code Playgroud)


And*_*ell 51

尝试firstDay选项(在选项选项卡中):

//getter
var firstDay = $('.selector').datepicker('option', 'firstDay');
//setter
$('.selector').datepicker('option', 'firstDay', 1);
Run Code Online (Sandbox Code Playgroud)


Mim*_*uni 8

使用第一天作为星期一:

$(function() {
    $( "#date_id" ).datepicker({ firstDay: 1 });
});
Run Code Online (Sandbox Code Playgroud)