我有两个“文本框”,我正在使用 jquery Datepicker 在“Textbox1”中选择日期。当我在 Textbox1 中选择日期时,我需要在 Textbox2 中自动显示日期,并在 Textbox1 中选择添加两天。
For Example: if selected Date in 'Textbox1' is '31/12/2015'
Display Date in 'Textbox2' as 02/02/2016...
我需要添加月份和年份并在 Textbox2 中添加和显示。
有什么建议吗……?
最佳答案
$("#textbox1").datepicker({
onSelect: function(dateText, inst) {
var someDate=new Date(dateText);
var duration =2; //day
$("#textbox2").val(new Date(someDate.getTime() + (duration * 24 * 60 * 60 * 1000)));
}
});
关于javascript - 使用 jquery 或 Javascript 添加天数到选定日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34268006/