2009-08-21 97 views

回答

46

嘗試firstDay選項(在選項標籤):

//getter 
var firstDay = $('.selector').datepicker('option', 'firstDay'); 
//setter 
$('.selector').datepicker('option', 'firstDay', 1); 
69

下面是一個例子配置我使用。看看「firstDay:1」的最後一行。 我認爲使用類似的語法時才這樣指定日期選擇器選項看起來更好;)

$('#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 
}) 
7

使用第一天,因爲星期一:

$(function() { 
    $("#date_id").datepicker({ firstDay: 1 }); 
}); 
-2
function getFirstDateOfThisWeek(d) 
    { 
     var TempDate = new Date(d || new Date());    
     TempDate.setDate(TempDate.getDate() + (@Config.WeekStartOn - 1 - TempDate.getDay() - 7) % 7);   
     return TempDate; 

    } 

    var StartDate = getFirstDateOfThisWeek(new Date()); //1st date of this week 
相關問題