【发布时间】:2020-09-02 15:06:54
【问题描述】:
我有两个月选择器“从”和“到”。我想根据“从”月份选择器在“到”月份选择器中选择月份。例如。如果在“从”月份选择器中选择了 2020 年 1 月,则“至”月选择器应该从 2020 年 2 月开始选择,并且范围应该最多可达 3 个月,即到 2020 年 4 月。
$("#dt_st").MonthPicker({
Button: false,
MonthFormat: "yy-mm",
autoclose: true
});
$('body').on('focus', '.end_date', function() {
var frm_month;
frm_month = document.getElementById().value;
$('.end_date').MonthPicker({
Button: false,
MonthFormat: "yy-mm",
MinMonth: frm_month;
autoclose: true
});
});
<script type="text/javascript" src="//code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" src="//code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<link rel="stylesheet" type="text/css" href="//code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css">
<script type="text/javascript" src="https://rawgithub.com/zorab47/jquery.ui.monthpicker/master/jquery.ui.monthpicker.js"></script>
<input type='text' id='dt_st' />
<input type='text' class='end_date' />
我尝试使用 MinMonth,但它没有获取值,并且日历也没有从 end_date 显示。请告诉我我犯了什么错误并对此给予指导。
【问题讨论】:
-
你似乎在
document.getElementById().value中缺少一个ID -
你能做一个小提琴吗?
标签: javascript jquery jquery-ui-datepicker