在我的情况下,我想在更改一个输入时动态更改注释
$('#text1').on('changeDate', function () {
var sdate = moment.utc((<any>$('#text1')).datepicker('getFormattedDate')).subtract(1, "days");
(<any>$("#LossDate")).datepicker('minDate', sdate.format("MM-DD-YYYY"));
});
我也尝试
$('#text1').on('changeDate', function () {
var sdate = moment.utc((<any>$('#text1')).datepicker('getFormattedDate')).subtract(1, "days");
(<any>$("#LossDate")).datepicker('setStartDate', sdate.format("MM-DD-YYYY"));
});
和
$('#text1').on('changeDate', function () {
var sdate = moment.utc((<any>$('#text1')).datepicker('getFormattedDate')).subtract(1, "days");
(<any>$("#LossDate")).datepicker('startDate', sdate.format("MM-DD-YYYY"));
});
和
$('#text1').on('changeDate', function () {
var sdate = moment.utc((<any>$('#text1')).datepicker('getFormattedDate')).subtract(1, "days");
(<any>$("#LossDate")).datepicker('SetstartDate', sdate.format("MM-DD-YYYY"));
});
但在我的情况下没有任何工作
答案 0 :(得分:2)
这是有效的javascript:
$(document).ready(function(){
$("#startdate").datepicker({
todayBtn: 1,
autoclose: true,
}).on('changeDate', function (selected) {
var minDate = new Date(selected.date.valueOf());
$('#enddate').datepicker('setStartDate', minDate);
});
$("#enddate").datepicker()
.on('changeDate', function (selected) {
var minDate = new Date(selected.date.valueOf());
$('#startdate').datepicker('setEndDate', minDate);
});
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.4.0/css/bootstrap-datepicker.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.4.0/js/bootstrap-datepicker.min.js"></script>
<div class="row">
<div class="col-xs-6">
<div class="form-group">
<label class="control-label">Start</label>
<input class="form-control" type="text" placehoder="Start Date" id="startdate"/>
</div>
</div>
<div class="col-xs-6">
<div class="form-group">
<label class="control-label">End</label>
<input class="form-control" type="text" placehoder="End Date" id="enddate"/>
</div>
</div>
</div>
&#13;
快乐编码
答案 1 :(得分:0)
使用此
{{1}}