我想從Jquery UI日曆中選擇一個月時獲取一個月的所有工作日。從jquery UI日曆中選擇一個月的所有工作日
下面是從date到date的選擇代碼,但是我需要的是,當我選擇一個月時,它應該打印整個月份的所有平日名稱。
eg: monday,tuesday,wednesday,thursday,friday,saturday,sunday
monday,tuesday,wednesday,thursday,friday,saturday,sunday
monday,tuesday,wednesday,thursday,friday,saturday,sunday
monday,tuesday,wednesday,thursday,friday,saturday,sunday
從所選月份的開始日期日期到結束月份。
<input id="from" />
<input id="to" />
<button id="getBetween">Get Between Dates</button>
<div id="results"></div>
$("#from").datepicker();
$("#to").datepicker();
$('#getBetween').on('click', function() {
var start = $("#from").datepicker("getDate"),
end = $("#to").datepicker("getDate"),
currentDate = new Date(start),
between = []
;
while (currentDate <= end) {
between.push(new Date(currentDate));
currentDate.setDate(currentDate.getDate() + 1);
}
$('#results').html(between.join('<br> '));
});
我編輯你想要的標題爲更好地理解......你可能會在編輯上面,這樣你就不會得到進一步的反對票。另請檢查我的新答案:https://stackoverflow.com/a/45861167/3001970,並使其正確,如果它適合你! – wittich