jQuery UI Datepicker after select/change month/year

陌路散爱 提交于 2019-11-30 21:07:44

Here is hacky hack.

http://jsfiddle.net/Xx4GS/3/

It works, highlights the next day( the next td in this case).

setTimeout is because I think jquery ui destroys the active date item, so we wait until we have the right one.

You might be able to use onSelect instead of .change, but not a big deal imo

I left a console.log in there so you can see a little bit of whats going on.

You can use the provided jQuery datepicker events onSelect and onChangeMonthYear.

Code:

$("#datep").datepicker({
    changeMonth: true,
    changeYear: true,
    onSelect: function () {
        console.log('s');
    },
    onChangeMonthYear: function () {
        console.log('o');
    }
});

Demo: http://jsfiddle.net/IrvinDominin/Xx4GS/

There is an event called "onSelect" having the date as its param. see this example:

$("#datePicker").datepicker({
    //the format
    dateFormat: "dd/mm/yy",
    //called when date is selected
    onSelect: function (date) {
        alert(date);
    }
});

Cou can find all the details in the api-doc: http://api.jqueryui.com/datepicker/#option-onSelect

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