定制年份的jQuery Datepicker

时间:2012-02-21 04:18:28

标签: jquery datepicker

我使用了来自http://keith-wood.name/datepick.html的datepicker,这很棒。

但我在控制年份范围方面存在问题。

这是我的代码。

$('#date_executed').datepick({ 
  dateFormat: 'MM dd, yy', 
  yearRange:'2011:2012',
  showOn: 'both',
  buttonImageOnly: true,
  buttonText: 'Calendar',
  buttonImage: "images/calendar.gif"
});

我需要将2009年添加到年度列表中,但我不想包括2010年。请帮助我谢谢。

2 个答案:

答案 0 :(得分:0)

将年份范围更改为yearRange:'2009:2012',然后删除2010年的负载,如下所示:

$("select.datepick-month-year option[value$='2010']").remove();

答案 1 :(得分:0)

你可以试试这个:

var yearRemoved = false;

$(".ui-datepicker").on("mouseenter", function() {

  if (!yearRemoved) {
    yearRemoved = true;          
    $("select.datepick-month-year option[value$='2010']").remove();
  }

});