且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

引导日期选择器清除值

更新时间:2023-01-30 14:35:29

实际上,27/11/2013代表的是当前日期。除非您在 changeDate 事件中写下,否则不会更新

Actually, what that 27/11/2013 represents is the current Date. Which will not get updated unless you write it on changeDate event.

所以你必须像


  1. 绑定开始日期 changeDate 事件。

  2. 开始增加所选日期。

  3. 再次设置递增的日期。

  4. 现在将此更新为结束日期使用 update 方法

  1. Bind the start date, with changeDate event.
  2. Increment the selected date in start.
  3. Again set back the incremented date.
  4. Now update this to end Date using update method

$('#end')datepicker ',toDate);

最后,你的代码将像

$('#start').datepicker({}).on('changeDate', function (ev) {
    var toDate = ev.date;
    toDate.setDate(toDate.getDate() + 1);
    $('#end').datepicker('update', toDate);
});
$('#end').datepicker({});