对于datepicker control在 jQuery UI 中,有没有办法将绝对范围与相对范围混合?
例如,我希望年份只回溯至 2005 年,但只显示到当前年份,您会如何表达?
我尝试过将两者混合使用,使用“2005:+0”之类的内容,但这会导致菜单中没有可用的年份。
年份范围文档:
yearRange
Type: String Default: '-10:+10'
Control the range of years displayed in the year drop-down: either relative to current year (-nn:+nn) or absolute (nnnn:nnnn).
最佳答案
给你。只需使用 Date 对象即可获取当前年份。
<强> Working Demo
演示代码
$(function ()
{
$('#txtStartDate').datepicker(
{
showOn: "both",
yearRange: "2005:" + new Date().getFullYear(),
dateFormat: "dd M yy",
firstDay: 1,
changeFirstDay: false,
changeMonth: true,
changeYear: true
});
});
关于javascript - 有没有办法在 jQuery Datepicker 上同时使用相对和绝对年份范围?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1228443/