如何在 jquery datepicker 的 title 中显示当前的完整日期:
2015 年 7 月 5 日
因为它只显示 2015 年 7 月
最佳答案
您可以在onSelect 中使用这样的函数
function showDateInTitle(picker) {
var span = picker.dpDiv[0].querySelector('.ui-datepicker-day'),
df, month;
if (span === null) {
month = picker.dpDiv[0].querySelector('.ui-datepicker-month');
if (!month) return;
span = document.createElement('span');
span.setAttribute('class', 'ui-datepicker-day');
df = document.createDocumentFragment();
df.appendChild(span);
df.appendChild(document.createTextNode('\u00a0'));
month.parentNode.insertBefore(
df,
month
);
}
span.textContent = picker.selectedDay;
}
在做出选择之前显示日期选择器之后,仍在通过 API 寻找处理程序
您可以将 afterShow 实现为 described here稍作修改以获取实例
$(function() {
$.datepicker._updateDatepicker_original = $.datepicker._updateDatepicker;
$.datepicker._updateDatepicker = function(inst) {
$.datepicker._updateDatepicker_original(inst);
var afterShow = this._get(inst, 'afterShow');
if (afterShow)
afterShow.apply((inst.input ? inst.input[0] : null), [inst]);
}
});
现在DEMO
关于javascript - 在 jquery datepicker 的标题中显示当前日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31231105/