【发布时间】:2019-07-08 17:16:55
【问题描述】:
我将以下文章 (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" />
【问题讨论】:
-
欢迎来到 Stack Overflow。在您的示例中,我没有看到此 Select 下拉菜单。请提供一个最小、完整和可验证的示例:stackoverflow.com/help/mcve
标签: javascript jquery jquery-ui datepicker date-range