在JQuery datepicker中更改禁用日的颜色 [英] Changing color of disabled days in a JQuery datepicker

查看:757
本文介绍了在JQuery datepicker中更改禁用日的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用JQuery显示日历(日期选择器)。



我已经禁用了周末,然后我试图禁用国庆日。 p>

这里是一个代码示例:

  function checkHolidays(date,holidaysArray ){
for(var i = 0; i< holidaysArray.length; ++ i){
if(date.getMonth()== holidaysArray [i] [0] .getMonth()
&&& amp;& amp;& amp;& amp;
}
}
return [true,''];
}

这是工作。但是我想改变单元格的颜色('holiday'css属性),这不工作。因为我将日期设置为禁用,所以不应用假日css属性。



但是如果我不禁用日期,即:

  return([true,'holiday',holidaysArray [i] [2]]); 

css属性正在工作。有任何想法吗?



编辑:



我将css规则更新为:

  .holiday,.ui-datepicker .holiday span 
{
background:none #FFEBAF;
border:1px Solid#BF5A0C;
}

现在它工作正常。



这篇文章帮助我:如何更改单元格颜色

解决方案

您可能会发现这些有用:



jQuery UI DatePicker:Disable Specified Days



jQuery用户界面:在jquery datepicker中突出显示多个日期



停用日期


I'm using JQuery to display a calendar (datepicker).

I've disabled weekends easily and then I've tried to disable national days.

So here a sample of code:

function checkHolidays(date, holidaysArray) {
    for (var i = 0; i < holidaysArray.length; ++i) {
        if (date.getMonth() == holidaysArray[i][0].getMonth()
            && date.getDate() == holidaysArray[i][0].getDate()) {
            return ([false, 'holiday', holidaysArray[i][1]]);
        }
    }
    return [true, ''];
}

This is working. But I want to change the color of the cell (the 'holiday' css property) and this is not working. Because I'm setting the day as disabled, the holiday css property is not applied.

But if I do not disable the date, i.e:

return ([true, 'holiday', holidaysArray[i][2]]);

The css property is working. Got any idea?

Edit:

I've updated my css rule to:

.holiday, .ui-datepicker .holiday span
{
     background: none #FFEBAF;
     border: 1px solid #BF5A0C;
}

And now it's working perfectly.

This post helped me: How to change cell color

解决方案

You may find these useful:

jQuery UI DatePicker: Disable Specified Days

jQuery UI: Highlight multiple dates in jquery datepicker

Disable date

这篇关于在JQuery datepicker中更改禁用日的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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