如何在jquery datepicker onclick中更改当天的背景颜色? [英] How to change the background color of current day in jquery datepicker onclick?

查看:94
本文介绍了如何在jquery datepicker onclick中更改当天的背景颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在angularjs中使用jQuery datepicker, 通过覆盖CSS,我将橙色背景显示为当前日期

I am using jQuery datepicker in angularjs, By overriding css I am displaying orange color background to the current date

.ui-state-highlight{
    background-color:orange;
}

现在,要求是单击时必须将当前日期的背景色更改为红色. 我尝试调用一个函数onSelect来更改日期选择器默认设置中的背景色,但这不起作用.如何实现此目的?

Now the requirement is the background color of current date must be changed to red when clicked. I have tried calling a function onSelect which changes the background color in datepicker defaults,but that's not working.How to achieve this?

推荐答案

您可以使用onSelect事件更改当前日期的CSS

You could use onSelect event to change the css of current date

onSelect: function(value, date) {
    date.dpDiv.find('.ui-datepicker-current-day')
        .addClass('ui-state-highlight');
}

我建议您不要使用上述机制,而是可以像这样覆盖.ui-datepicker-current-day

I would recommend against using mechanism above, instead you could override .ui-datepicker-current-day class like this

.ui-datepicker-current-day{
    background-color:orange;
}

不需要JS.

这篇关于如何在jquery datepicker onclick中更改当天的背景颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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