我将在以下文章 ( jquery ui date range 15 day between two date ) 中使用的 JQuery UI 日期选择器范围用于我的表单,它工作正常,问题是我有另一个下拉列表列,我想清除日期列中的 1 个当我从下拉列表中选择一个值时。 下面是我在文章中使用的代码:
$(function () {
$("#txtFrom").datepicker({
onSelect: function(selectedDate) {
//$("#cal4").datepicker("setDate", selectedDate);
var date = $(this).datepicker("getDate");
date.setDate(date.getDate() + 15);
$("#txtTo").datepicker("setDate", date);
$("#txtTo").datepicker("option", "minDate", selectedDate);
$("#txtTo").datepicker("option", "maxDate", date);
}
});
$("#txtTo").datepicker({
changeMonth: true,
changeYear: true
})
});
<link href="https://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<input type="text" id="txtFrom" />
<input type="text" id="txtTo" />
最佳答案
是这样的吗?变化触发事件
$("#txtTo").datepicker({
changeMonth: true,
changeYear: true
}).on( "change", function() {
//add your code ref: txtFrom
}),
关于javascript - jquery ui datepicker range clear value 基于另一个选择的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54694472/