With the jQuery datepicker, how does one change the year range that is displayed? On the jQuery UI site it says the default is "10 years before and after the current year are shown". I want to use this for a birthday selection and 10 years before today is no good. Can this be done with the jQuery datepicker or will I have to use a different solution?

链接到datepicker演示:http://jqueryui.com/demos/datepicker/#dropdown-month-year

推荐答案

如果您稍微往下看一下演示页面,您会看到一个"限制日期 Select 器"部分.使用下拉菜单指定"Year dropdown shows last 20 years"演示,点击查看来源:

$("#restricting").datepicker({ 
    yearRange: "-20:+0", // this is the option you're looking for
    showOn: "both", 
    buttonImage: "templates/images/calendar.gif", 
    buttonImageOnly: true 
});

你也会想这么做(显然是把-20改成-100之类).

Jquery相关问答推荐

多个 AJAX 调用;获取所有失败的呼叫

在 Laravel 中使用 jQuery post 按相关值过滤 Select 选项,如何显示从控制器返回的数据?

:eq Jquery,我似乎无法显示第一个之后的元素

在学习 jQuery 之前学习 JavaScript 是个好主意吗?

使用 jQuery / javascript 测试链接是否是外部的?

如何在 jquery 中从这个日期减go 一周?

在 Javascript 中启用和禁用 Div 及其元素

jQuery .get 错误响应函数?

谷歌图表重绘/zoom 窗口调整大小

使用 jQuery 刷新(重新加载)页面一次?

blueimp 文件上传插件中的 maxFileSize 和 acceptFileTypes 不起作用.为什么?

如何使用 jQuery 更改文本

移动 chrome 在滚动时触发调整大小事件

如何使用 jquery 动态更改 iframe 中的内容?

如何使 jQuery Contains 不区分大小写,包括 jQuery 1.8+?

超时 jQuery 效果

一起使用 JQuery-Mobile/Phonegap 的正确方法?

Jquery Select 器输入[type=text]')

如何使用 jQuery 或仅使用 Javascript 将按钮重定向到另一个页面

为什么我应该创建异步 WebAPI 操作而不是同步操作?