简体   繁体   中英

Setting Yesterday to Jquery datepicker

I am trying to set yesterdays day to a Jquery datapicker as follows:

$(".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.

Could anyone point out what I am doing wrong.

From http://api.jqueryui.com/datepicker/#method-setDate :

$(".datepicker").datepicker("setDate", -1)

Demo

$( ".datepicker" ).datepicker({ defaultDate: -1 });

http://docs.jquery.com/UI/Datepicker#option-defaultDate提供,这应该是诀窍

It's worked for me ...

$(".datepicker")..datepicker("setDate", "-1d");

link bootstrap datepicker

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM