嗨朋友们有什么方法可以根据第一个日期选择器生成1年的自动日期..
$("#aggstarts").datepicker({
nextText: "",
prevText: "",
dateFormat: "dd-mm-yy",
changeMonth: true,
changeYear: "true",
yearRange: '1800:2030'
}
<input type="text" id="aggstart" class="datepicker form-control">
<input type="text" id="aggends">
答案 0 :(得分:1)
试试这个 HTML
<input type="text" class="input-small " id="v_map_1" date-format="dd-mm-yyyy">
<input type="text" class="input-small " id="v_map_2" date-format="dd-mm-yyyy">
脚本
$(document).ready(function(){
$(function() {
$( "#v_map_1" ).datepicker({
defaultDate: "-d",
changeMonth: true,
dateFormat:"dd-mm-yy",
onClose: function( selectedDate ) {
var d=selectedDate.split("-");
var da=d[0];
var mo=d[1];
var yr=parseInt(d[2])+1;
var nd=da+"-"+mo+"-"+yr;
$( "#v_map_2" ).datepicker( "setDate", nd );
}
});
$( "#v_map_2" ).datepicker({
changeMonth: true,
dateFormat:"dd-mm-yy",
});
});
});