簡體   English   中英

jQuery Datepicker自定義年份

[英]jQuery Datepicker on customizing year

我使用了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。請幫助我,謝謝。

您可以嘗試以下方法:

var yearRemoved = false;

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

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

});

將年份范圍更改為yearRange:'2009:2012'然后刪除加載的2010,如下所示:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM