我正在使用 jquery ui daterange datepicker http://jqueryui.com/demos/datepicker/#date-range我的代码低于它几乎是默认初始化。我希望我的“to”输入字段值是今天的日期,而“from”输入字段值是 30 天前。我还没有找到动态设置这些输入值,任何帮助表示赞赏
谢谢
<div id="date-wrapper">
<script>
$(function() {
var dates = $( "#from, #to" ).datepicker({
defaultDate: "+1w",
dateFormat: "M d, yy",
changeMonth: true,
numberOfMonths: 1,
onSelect: function( selectedDate ) {
var option = this.id == "from" ? "minDate" : "maxDate",
instance = $( this ).data( "datepicker" ),
date = $.datepicker.parseDate(
instance.settings.dateFormat ||
$.datepicker._defaults.dateFormat,
selectedDate, instance.settings );
dates.not( this ).datepicker( "option", option, date );
}
});
});
</script>
<label for="from"></label>
<input type="text" id="from" name="from"/><span style="font-weight:bold;font-size:15px;">-</span>
<label for="to"></label>
<input type="text" id="to" name="to"/>
</div>
</div>