jQuery UI Datepicker - Disable current date but NOT the highlight

与世无争的帅哥 提交于 2019-12-22 05:13:26

问题


I have the following code which disables the current date by setting minDate to current date + 1:

    var today = new Date();
    var tomorrow = new Date();
    tomorrow.setDate(today.getDate() + 1);

        $("#minDate").datepicker({
            showOn: "none",
            minDate: tomorrow,
            dateFormat: "DD dd-mm-yy",
            onSelect: function(dateText) {
                minDateChange;
            },
            inputOffsetX: 5,
        });

The problem is that I want to disable the current date, but still keep it highlighted (Blue border around the date) in the calendar.

Is there a native way to do this using the datepicker or do I have to create a highlight script myself?


回答1:


you don't need to set today and tomorrow as a variable. just set minDate: 1




回答2:


The datepicker has a class on todays date called "ui-datepicker-today", so I simply added a class to that:

$(".ui-datepicker-today span").addClass("ui-state-hover")


来源:https://stackoverflow.com/questions/16059192/jquery-ui-datepicker-disable-current-date-but-not-the-highlight

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