user2881809
user2881809

Reputation:

Jquery datepicker How set class when onSelect date?

$("#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
                }

            }

            });

I would like set class ui-state-custom when onSelect date (not beforeShowDay !).

Tell me please how make it?

Upvotes: 0

Views: 3791

Answers (2)

Milind Anantwar
Milind Anantwar

Reputation: 82231

You should have checked the console for errors. little embarrassing to explain, its not assClass() its addClass():

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

highlight selected date:

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

Demo

Upvotes: 1

JegsVala
JegsVala

Reputation: 1857

Try this, I hope it should be work fine.

$("#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
            }

        }

        });

Upvotes: 1

Related Questions