【问题标题】:Highlight the first day of each month in jQuery-ui Datepicker在jQuery-ui Datepicker中突出显示每个月的第一天
【发布时间】:2012-12-20 15:01:17
【问题描述】:

我不得不对我的 jQuery 日期选择器的 CSS 进行一些修改。不幸的是,在此过程中,我设法突出了每个月的第一天。我需要寻找什么房产?我必须从今天的日期中删除样式以执行其他 CSS。我已经能够做到。但我不想要这种副作用....

这是我添加的行:

.ui-datepicker-current .ui-datepicker-today .ui-state-highlight { background: transparent !important;}

【问题讨论】:

    标签: jquery jquery-ui date jquery-ui-datepicker


    【解决方案1】:

    您可以为此使用beforeShowDay 事件。此事件的主要功能是启用或禁用日历上的特定日期。但是,它也可以用于为特定日期分配一个特殊的类:

    $(".datepicker").datepicker({
        beforeShowDay: function(date) {
            return [true, date.getDate() == 1 ? "first-class" : ""];
        }
    });
    

    Demo here

    【讨论】:

    • 我已经在“beforeShowDay”使用了一个函数,它返回一个值。我可以让“beforeShowDay”做两件事,以便我可以包含您的建议吗?
    • 是的。它应该返回一个数组[true/false, classname, tooltip text]。返回数组中的第 2 项和第 3 项是可选的。您需要添加/修改第二项。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-29
    • 2017-01-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多