隐藏平日的日期和具体的日期 [英] Hide weekdays and specific dates of jaquery datepicker

查看:125
本文介绍了隐藏平日的日期和具体的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个隐藏星期几的日期戳的功能。需要,除此之外,隐藏特定的日子...
例如:09/09/2014,10/10/2014

I have a function that hides the days of the weeks datepicker. Need, in addition to this, hide specific days ... Ex: "09/09/2014", "10/10/2014"

是我的jquery ...

This is my jquery ...

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


推荐答案

创建您要排除的日子阵列在 beforeShowDay 选项中添加检查:

Create an array of the days you want to exclude and add checking for them in the beforeShowDay option:

$(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排除特定日期和天

这是一个调整版本的示例,用于排除刚才发现的具体日期这里: http://www.jquerybyexample .net / 2013/03 / hide-disable-dates-in-jquery-ui-datepicker.html

This is an adjusted version of an example for excluding specific dates I just found here: http://www.jquerybyexample.net/2013/03/hide-disable-dates-in-jquery-ui-datepicker.html

这篇关于隐藏平日的日期和具体的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆