jQuery Datepicker 自定义年份

发布于 2025-01-07 03:41:44 字数 457 浏览 2 评论 0原文

我使用了 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 年。请帮助我,谢谢。

I have used datepicker from http://keith-wood.name/datepick.html and it was great.

But I have a problem on controlling the year range.

Here's my code.

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

I need to add 2009 to the list of year but I don't want to include 2010. please help me thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

戏蝶舞 2025-01-14 03:41:44

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

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

Change the year range to yearRange:'2009:2012' then remove the 2010 on load, like this:

$("select.datepick-month-year option[value$='2010']").remove();
指尖凝香 2025-01-14 03:41:44

你可以试试这个:

var yearRemoved = false;

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

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

});

You can try this:

var yearRemoved = false;

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

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

});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文