How to change the background color of current day in jquery datepicker onclick?

旧时模样 提交于 2019-12-25 18:44:33

问题


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;
}

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?


回答1:


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');
}

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;
}

that will not require JS.



来源:https://stackoverflow.com/questions/24449323/how-to-change-the-background-color-of-current-day-in-jquery-datepicker-onclick

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!