显示 jQuery 日期选择器年份 [英] jQuery datepicker years shown

查看:31
本文介绍了显示 jQuery 日期选择器年份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 jQuery 日期选择器,如何更改显示的年份范围?在 jQuery UI 站点上,它说默认值是显示当前年份之前和之后的 10 年".我想用它来选择生日,10 年前的今天是不行的.这可以使用 jQuery 日期选择器完成还是我必须使用不同的解决方案?

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?

日期选择器演示链接:http://jqueryui.com/demos/datepicker/#dropdown-month-year

推荐答案

如果您稍微向下看一下演示页面,您会看到限制日期选择器"部分.使用下拉菜单指定Year dropdown shows last 20 years"演示,然后点击查看源代码:

If you look down the demo page a bit, you'll see a "Restricting Datepicker" section. Use the dropdown to specify the "Year dropdown shows last 20 years" demo , and hit view source:

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

你会想要做同样的事情(显然将 -20 更改为 -100 或其他什么).

You'll want to do the same (obviously changing -20 to -100 or something).

这篇关于显示 jQuery 日期选择器年份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆