English 中文(简体)
j日期+1 增加了10天
原标题:jquery datepicker date +1 is adding 10 days
  • 时间:2012-05-09 06:41:32
  •  标签:
  • jquery

我遵循法典

$("#in").datepicker({
    minDate: 0,
    onSelect: function (dateText, inst) {
        dateText = new Date(dateText);
        dateText = dateText.getDate()+1;
        $( #out ).datepicker("option",  minDate , dateText);
    }
});

Example: https://jsfiddle.net/ANYTA/1/

然而,<代码>out 日皮克尔正在增加10天而不是1天。 为了使其发挥预期的作用,可以做些什么修改? 非常感谢

最佳回答
dateText = dateText.setDate(dateText.getDate()+1);

<>0>

somedate.setDate(days);
  1. <><>>><>>>><>>>>>>>>> is

  2. 预期数值为1-31>,但其他数值允许:

      2.1) 0 will result in the last hour of the previous month

       2.1) -1 will result in the hour before the last hour of the previous month

  1. 月度为31天,月度为32天,下一个月的第一天。

  2. 如果每月有30天,则有32天,下一个月的第二天。


页: 1

$("#in").datepicker({
    minDate: 0,
    onSelect: function(dateText, inst) {
       var actualDate = new Date(dateText);
       var newDate = new Date(actualDate.getFullYear(), actualDate.getMonth(), actualDate.getDate()+1);
        $( #out ).datepicker( option ,  minDate , newDate );
    }
});

$("#out").datepicker();

<>DEMO

问题回答

Try:

dateText.setDate(dateText.getDate() + 1);

抵达 日期按月1日至31日回来,因此在其中增加一个日期没有意义。

定 义 日期为月日,因此,如果你在月日增加一天,你将有效地增加一天。

(Also, setDate is smart sufficient to address summary, i.e. 31 Jan + 1 = 1 Feb)





相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签