javascript 将昨天设置为 Jquery 日期选择器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16990260/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Setting Yesterday to Jquery datepicker
提问by Shamim Hafiz
I am trying to set yesterdays day to a Jquery
datapicker
as follows:
我试图将昨天的一天设置Jquery
datapicker
为如下:
$(".datepicker").datepicker("setDate", (new Date().getDate() - 1) );
However, I am always getting todays date. The code is located in $(document).ready
and it does get excuted, cause if I comment out the line abobve, no value shows up.
但是,我总是收到今天的日期。该代码位于$(document).ready
并且它确实被执行了,因为如果我注释掉上面的行,则不会显示任何值。
Could anyone point out what I am doing wrong.
谁能指出我做错了什么。
回答by mishik
From http://api.jqueryui.com/datepicker/#method-setDate:
从 http://api.jqueryui.com/datepicker/#method-setDate:
$(".datepicker").datepicker("setDate", -1)
回答by Eric Wich
$( ".datepicker" ).datepicker({ defaultDate: -1 });
That ought to do the trick, courtesy of http://docs.jquery.com/UI/Datepicker#option-defaultDate
这应该可以解决问题,由http://docs.jquery.com/UI/Datepicker#option-defaultDate 提供
回答by Hossain Misho
It's worked for me ...
它对我有用...
$(".datepicker")..datepicker("setDate", "-1d");
link bootstrap datepicker
链接引导日期选择器