如何使用jquery datepicker添加一个日期 [英] how to add a day to a date using jquery datepicker

查看:100
本文介绍了如何使用jquery datepicker添加一个日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站上有两个文本框,用于提取日期和下拉日期,均使用jquery日期选择器。



我无法将日期值设置为在选择的捡拾日期之前一天。



这是我有的:

 $ $ $'$。$('。pickupDate')。change(function(){
var date2 = $('。pickupDate')。datepicker('getDate','+ 1d');
$('。dropoffDate')。datepicker('setDate',date2);
});

以上将执行,但是下拉文本框中的值将匹配拾取值而不是一个提前一天例如:如果我选择01-01-2010上述代码在下拉框中返回01-01-2010,而不是02-01-2010。



任何想法?

感谢您的帮助,
Rich

解决方案

尝试这样:

  $('。pickupDate')。change(function(){
var date2 = $ '.pickupDate')。datepicker('getDate','+ 1d');
date2.setDate(date2.getDate()+ 1);
$('。dropoffDate' setDate',date2);
});


I have 2 textboxes on my site for pickup date and drop off date both using the jquery date picker.

I am having trouble setting the drop off date value to be one day ahead of the pickup date that was selected.

Here is what I have:

$('.pickupDate').change(function() {
    var date2 = $('.pickupDate').datepicker('getDate', '+1d'); 
    $('.dropoffDate').datepicker('setDate', date2);
});

The above will execute but the value in the drop off textbox will match the pickup value instead of being one day ahead. eg: if I select 01-01-2010 the above code returns 01-01-2010 in the drop off box instead of 02-01-2010.

Any thoughts?

Thanks for your help, Rich

解决方案

Try this:

 $('.pickupDate').change(function() {
  var date2 = $('.pickupDate').datepicker('getDate', '+1d'); 
  date2.setDate(date2.getDate()+1); 
  $('.dropoffDate').datepicker('setDate', date2);
});

这篇关于如何使用jquery datepicker添加一个日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆