开发者

Using setDate with jQueryUi datepicker

开发者 https://www.devze.com 2023-02-04 01:09 出处:网络
I\'m trying to set the date of another datepicker exactly 1 year on from the original datepicker on close.

I'm trying to set the date of another datepicker exactly 1 year on from the original datepicker on close.

I have the following code:

$("#myDatepi开发者_开发知识库cker1").datepicker({
onClose: function(dateText, inst) {
$("#myDatepicker2").datepicker("setDate", dateText +1y);
}
});

As you can guess this isn't working.

Any help would be great.

Thanks in advance!

Richard


You can try something like that:

d = $("#myDatepicker1").datepicker("getDate");
$("#myDatepicker2").datepicker("setDate", new Date(d.getFullYear()+1,d.getMonth(),d.getDate()));

EDIT:

This is the solution to add one year, just to make sure that this is the piece which was missing right?! the on close it`s working fine right?!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号