我用“从日期”和“到日期”制作了一个范围日期选择器。
这里代码:
From <input type="text" id="from" name="from" style="width: 80px" readonly>
To <input type="text" id="to" name="to" style="width: 80px" readonly>
<script>
$(function() {
$( "#from" ).datepicker({
showOn: "button",
buttonImage: "images/calendar.png",
buttonImageOnly: true,
minDate: 0,
changeMonth: true,
beforeShowDay: $.datepicker.noWeekends,
onSelect: function( selectedDate ) {
$( "#to" ).datepicker( "option", "minDate", selectedDate );
}
});
$( "#to" ).datepicker({
showOn: "button",
buttonImage: "images/calendar.png",
buttonImageOnly: true,
changeMonth: true,
beforeShowDay: $.datepicker.noWeekends,
onSelect: function( selectedDate ) {
$( "#from" ).datepicker( "option", "maxDate", selectedDate );
}
});
});
</script>
我想要做的是:当用户在 选择特定日期时#from
,我想将最大日期设置为#to
,例如 10 天,从 中的日期开始#from
。
我该怎么做?谢谢。