如何更改默认突出显示的“今天"日期选择器中的日期 [英] How to change default highlighted "today" date in datepicker

查看:25
本文介绍了如何更改默认突出显示的“今天"日期选择器中的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 datepicker 在两个日期字段(从日期和到日期)中选择日期.

I'm using datepicker for selecting dates in two date fields (from date and to date).

在那些中,默认突出显示的日期是今天的日期.我需要在第二个日期选择器中将默认突出显示的日期更改为其他日期.(例如今天 + 8 天).

In those, the default highlighted date is today date. I need to change the default highlighted date to some other day in the second datepicker. (as a example today + 8 days).

我该如何正确执行此操作?

How can I do this correctly ?

以下是我的日期选择器,

following are my datepickers,

$(function() {
$( "#datepicker" ).datepicker();
$( "#datepicker" ).datepicker("option", "dateFormat", "yy-mm-dd"); // ISO 8601
$( "#datepicker2" ).datepicker();
$( "#datepicker2" ).datepicker("option", "dateFormat", "yy-mm-dd");
});

谢谢.

----------------------------------- 更新------------------------------------

---------------------------------- Update -----------------------------------------------

按照迈克尔的屏幕截图,

Following the screen shot for Michael,

我把下面的,

$( "#datepicker2" ).datepicker("option", "defaultDate", +2);

您仍然可以看到第 21 天(今天)是高亮显示,而第 23 天是用黑线包围的.我需要看到 23 看起来像 21 与 hi 照明.无需突出显示 21.

You can see still the 21 day (today) is Highlighting and 23 is bordered with black line. I need see 23 looks like 21 with hi lighting. No need to highlight 21.

推荐答案

    $( "#datepicker" ).datepicker("option", "defaultDate", +8);

来源:http://api.jqueryui.com/datepicker/#option-defaultDate

当前日期将始终作为日期选择器的一部分突出显示.没有关闭此功能的选项.就是让用户清楚什么是今天".但是,您可以使用一些 CSS 覆盖此图形的外观:

The current date will always be highlighted as part of the datepicker. There is no option to turn off this feature. It is to make clear to the user what "today" is. You can however override the graphical appearance of this w/ some CSS:

    .ui-datepicker-today a.ui-state-highlight {
        border-color: #d3d3d3;
        background: #e6e6e6 url(/themeroller/images/ui-bg_glass_75_e6e6e6_1x400.png) 50% 50% repeat-x;;
        color: #555555;    
    }
   .ui-datepicker-today.ui-datepicker-current-day a.ui-state-highlight {
        border-color: #aaaaaa;
        background: #ffffff url(images/ui-bg_glass_65_ffffff_1x400.png) 50% 50% repeat-x;
        color: #212121;
    }

工作jsfiddle:http://jsfiddle.net/EpWud/

Working jsfiddle: http://jsfiddle.net/EpWud/

这假设您使用的是默认主题 - 但您可以对任何主题执行相同的练习.只需像上面的代码一样覆盖样式即可.然而,这个 CSS 是不完整的.您需要为其他情况进行覆盖,例如 :hover 状态.

This assumes you're using the default theme - but you can do this same practice for any theme. Just override the styles like the code above. This CSS is incomplete, however. You'll need to make overrides for other cases, like the :hover state.

这篇关于如何更改默认突出显示的“今天"日期选择器中的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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