jQuery datepicker年显示 [英] jQuery datepicker years shown

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

问题描述

使用jQuery datepicker,如何更改显示的年份范围?在jQuery UI网站上,它表示默认为今年前后10年。我想用这个生日快乐,10年前,今天不好。这可以通过jQuery datepicker来完成,还是要使用不同的解决方案?

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

link to datepicker demo: http://jqueryui.com/demos/datepicker/#dropdown-month-year

推荐答案

如果您往下看演示页面,您将看到一个限制日期戳部分。使用下拉列表来指定过去20年的年度下拉列表演示,并点击查看来源:

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 datepicker年显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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