[英]How to calculate a Date given only month, week number within that month, and day of week
[英]How to display a date as select tag (only day of the week and date of the month)
您可能無法修改datepicker來執行此操作(我很樂意向其他人承認),但是您可以輕松地將日期添加到標准的select控件中。
在這段代碼中,我使用了datepicker UI中的formatDate,因此您需要包括jQuery UI,或者至少包括datepicker組件,它才能正常工作。
下面的示例將從當前日期開始的10天添加到ID為“ mySelect”的select元素。
$(function () {
var today = new Date();
var date = new Date();
for (x = 0; x <= 9; x++) {
date.setDate(today.getDate() + x);
textDate = $.datepicker.formatDate('D, dd-M', date);
$('#mySelect')
.append($("<option></option>")
.attr("value", textDate)
.text(textDate));
}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.