如何通过在实际日期上添加 3 天来设置 jquery 日期选择器的选定日期?
例如从 11/01/2011 到 11/04/2011
我当前的代码不起作用!
<script type="text/javascript">
$(function() {$("#datepicker").datepicker();});
//Set DatePicker to actual date + 3 days
$('#dateselector').datepicker("setDate", new Date(date.getMonth()+"/"+(date.getDate()+3)+"/"+date.getFullYear()) );
</script>
最佳答案
$('#datepicker').datepicker("setDate", "+3");
工作示例:http://jsfiddle.net/EryYr/1/
引用文档:
setDate
.datepicker( "setDate" , date )
... The new date may be a Date object or a string in the current date format (e.g. '01/26/2009'), a number of days from today (e.g. +7) or a string of values and periods ('y' for years, 'm' for months, 'w' for weeks, 'd' for days, e.g. '+1m +7d'), or null to clear the selected date.
关于jQuery ui 1.7.3 datepicker 设置选定日期+ 3 天,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8139617/