Jquery datepicker如何在onSelect日期设置类?

时间:2014-05-27 09:03:18

标签: jquery jquery-ui datepicker

$("#datepicker").datepicker({
            beforeShowDay: function(date)
            {
                ....
            },
            onSelect: function(date) {
                alert(date);

                    $(this).addClass('ui-state-custom'); //try one - not work
                    return[true, "ui-state-custom", "closed"]; //try two - not work
                }

            }

            });

我想在ui-state-custom日期(不是onSelect!)时设置课程beforeShowDay

请告诉我怎么做?

2 个答案:

答案 0 :(得分:1)

您应该检查控制台是否有错误。有点尴尬的解释,它不是assClass() addClass()

 $(this).addClass('ui-state-custom'); //try one - should work

突出显示所选日期:

#ui-datepicker-div .ui-state-active {
 background: blue;
 color: #555555;
 border: 1px solid #D3D3D3;
}

<强> Demo

答案 1 :(得分:1)

试试这个,我希望它应该可以正常工作。

$("#datepicker").datepicker({
        beforeShowDay: function(date)
        {
            ....
        },
        onSelect: function(date) {
            alert(date);

                $(this).addClass('ui-state-custom'); //try one - not work
                return[true, "ui-state-custom", "closed"]; //try two - not work
            }

        }

        });