【问题标题】:Hide weekdays and specific dates of jquery datepicker隐藏jquery datepicker的工作日和特定日期
【发布时间】:2014-08-16 21:57:06
【问题描述】:

我有一个隐藏星期日期选择器的功能。除此之外,还需要隐藏特定的日子...... 例如:“09/09/2014”、“10/10/2014”

这是我的 jquery ...

jQuery("#wpsc_checkout_form_9998").datepicker( 
            "option", 
            "beforeShowDay", 
            function(date) { 
                var day = date.getDay();
                return [(day != 4) && (day != 2), ''];
            }
        );

【问题讨论】:

    标签: jquery datepicker


    【解决方案1】:

    创建一个包含您要排除的日期的数组,并在 beforeShowDay 选项中添加对它们的检查:

    $(document).ready(function () {
      var arrDisabledDates = {};
      arrDisabledDates[new Date('08/08/2014')] = new Date('08/08/2014');
      arrDisabledDates[new Date('08/30/2014')] = new Date('08/30/2014');
    
       $('#txtDate').datepicker({
        beforeShowDay: function (date) {
                            var day = date.getDay(),
                                bDisable = arrDisabledDates[date];
                             if (bDisable) return [false, '', '']
                             else return [(day != 4) && (day != 2)];
          }
       });
    });
    

    在此处查找演示:jQuery Datepicker excluding specific dates and days

    这是我刚刚在此处找到的排除特定日期的示例的调整版本:http://www.jquerybyexample.net/2013/03/hide-disable-dates-in-jquery-ui-datepicker.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-01-28
      • 1970-01-01
      • 1970-01-01
      • 2021-12-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多