KDe*_*Dee 5 jquery jquery-ui jquery-ui-datepicker
我想在日历中获取当前活动月份的月份.例如,当前月份(2012年12月)包括(但未显示)11月26日至30日,beforeShowDay(日期)功能包括在"日期"中循环时.我想在开始时获得12月'11'(基于0的索引),但无法找到如何获得这个.
使用date.getMonth() + 1不起作用,因为它首先给我Novembers月号,但我想要Dec,因为那是日历中的选定月份.当我最终通过"日期"进入循环时,我得到了Dec,但是那时候已经很晚了.
任何想法如何得到这个?
如果我理解正确,这就是您正在寻找的:http://jsfiddle.net/kACfV/
// Initially, set current date as the active month.
var activeMonth = new Date().getMonth() + 1;
$(function() {
$("#datepicker").datepicker({
// This is run before beforeShowDay(date).
onChangeMonthYear: function (year, month, inst) {
activeMonth = month; // Store active month when month is changed.
},
beforeShowDay: function (date) {
// Do your logic here with activeMonth.
console.log(date + " > " + activeMonth);
return [true, ""]
}
});
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1290 次 |
| 最近记录: |