JQuery UI Datapicker:如何添加下一个/上一年的按钮

时间:2023-01-27 15:56:19

I use the feature of selecting a year with a dropdown. I use it to set birthdays of people at least 18 years old. So far it works perfectly. I have set it up using theseg parameters:

我使用选择下拉年份的功能。我用它来设置至少18岁的人的生日。到目前为止它完美无缺。我已使用theseg参数进行设置:

        $('#datepicker').datepicker({
        changeMonth: true,
        changeYear: true,
                    dateFormat: 'dd-mm-yy',
                    minDate: '-100Y',
                    maxDate: '-18Y'
    });

However I'd like to have year navigation. Is it possible to add a next/previous year button?

但是我想要年份导航。是否可以添加下一个/上一年的按钮?

Thanks in advance for any help!

在此先感谢您的帮助!

2 个解决方案

#1


15  

Check this : http://jqueryui.com/demos/datepicker/dropdown-month-year.html its part of datepicker plug in

检查一下:http://jqueryui.com/demos/datepicker/dropdown-month-year.html它的datepicker插件的一部分

$(function() {
  $('#datepicker').datepicker({
   changeMonth: true,
   changeYear: true
  });
 });

#2


0  

In order to complete the @PranayRana's answer, jQuery UI gives you the possibility to select the year with the option changeYear, and you are also able to specify the date range to your datepicker (for a birth date field for example).

为了完成@PranayRana的答案,jQuery UI使您可以选择changeYear选项,并且您还可以为datepicker指定日期范围(例如,对于出生日期字段)。

Here's an example :

这是一个例子:

$(".datepicker").datepicker({
    changeYear: true, // Add the ability to select the year
    yearRange: '1930:2000', // Set the year range selection from 1930 to 2000
});

#1


15  

Check this : http://jqueryui.com/demos/datepicker/dropdown-month-year.html its part of datepicker plug in

检查一下:http://jqueryui.com/demos/datepicker/dropdown-month-year.html它的datepicker插件的一部分

$(function() {
  $('#datepicker').datepicker({
   changeMonth: true,
   changeYear: true
  });
 });

#2


0  

In order to complete the @PranayRana's answer, jQuery UI gives you the possibility to select the year with the option changeYear, and you are also able to specify the date range to your datepicker (for a birth date field for example).

为了完成@PranayRana的答案,jQuery UI使您可以选择changeYear选项,并且您还可以为datepicker指定日期范围(例如,对于出生日期字段)。

Here's an example :

这是一个例子:

$(".datepicker").datepicker({
    changeYear: true, // Add the ability to select the year
    yearRange: '1930:2000', // Set the year range selection from 1930 to 2000
});