gpt4 book ai didi

javascript - 在 jquery datepicker 的标题中显示当前日期

转载 作者:数据小太阳 更新时间:2023-10-29 04:11:27 30 4
gpt4 key购买 nike

如何在 jquery datepicker 的 title 中显示当前的完整日期:

2015 年 7 月 5 日 因为它只显示 2015 年 7 月

enter image description here

最佳答案

您可以在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/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com