【问题标题】:jQuery datepicker hide dates in between two monthsjQuery datepicker 隐藏两个月之间的日期
【发布时间】:2015-03-04 15:47:09
【问题描述】:

numberOfMonths: 2的选项有没有办法隐藏两个月之间的日期。

我的意思是启用第一个月的前几天和第二个月的后几天,两个月之间的日子将被隐藏。

预期的输出将如下所示:

要隐藏的红色部分

更新: 只有那些 [2 月 23 日至 28 日和 5 月 1 日至 10 日] 需要变灰。

我想隐藏 3 月的 [Apr 1-5] 和 4 月的 [Mar 30-31]。

Sample JsFiddle

【问题讨论】:

  • 3 月初(2 月 23 日至 28 日)和 4 月底(5 月 1 日至 10 日)灰显的日期怎么办?
  • @j08691:那些 [2 月 23 日至 28 日和 5 月 1 日至 10 日] 只需要变灰。我想隐藏 3 月的 [Apr 1-5] 和 4 月的 [Mar 30-31]
  • 据我记得,那些红色的日期不是可以选择的吗?因此,如果他们在 3 月,他们应该能够点击 4 月 2 日,并且应该提供那个日期。

标签: jquery-ui datepicker jquery-ui-datepicker


【解决方案1】:

这个让我很难过,但我认为你可以用一些 CSS 来做到这一点:

div.ui-datepicker-group-first td:not(.ui-datepicker-other-month) ~ td.ui-datepicker-other-month {
    visibility:hidden;
}
div.ui-datepicker-group-last td {
    visibility:hidden;
}
div.ui-datepicker-group-last td.ui-datepicker-other-month ~ td:not(.ui-datepicker-other-month), div.ui-datepicker-group-last td:not(.ui-datepicker-other-month), div.ui-datepicker-group-last td:not(.ui-datepicker-other-month) ~ td.ui-datepicker-other-month {
    visibility:visible;
}

jsFiddle example

【讨论】:

  • 只是有点?似乎完全按照你的要求做。
猜你喜欢
  • 1970-01-01
  • 2015-09-29
  • 2019-03-28
  • 2011-01-01
  • 2011-06-06
相关资源
最近更新 更多