我在一页中有多个日期选择器。
我使用类名来设置选项,例如出现。
$('.datepickers').datepicker({
dateFormat: "yy-mm-dd",
showButtonPanel: true,
changeMonth: true,
changeYear: true,
showOtherMonths: true,
selectOtherMonths: true,
showWeek: true
});
然后,我想为其中两个设置 onSelect 事件。
$('#to').datepicker({
onSelect: function(selectedDate) {
$('#from').datepicker("option", "minDate", selectedDate);
}
});
其他人的类似 onSelect 事件设置。
但是,这行不通。除了按 id 单独设置所有选项之外,有关如何解决此问题的任何建议?
最佳答案
您是否尝试过以下语法?您不想再次 _init 日期选择器小部件。您只想更改一个选项。这是使用 jquery ui 小部件实现此目的的方法。
$('#to').datepicker('option', 'onSelect', function(selectedDate) {
$('#from').datepicker("option", "minDate", selectedDate);
});
关于jquery-ui - jQuery UI 多个日期选择器 : set individual event by id after setting options by class,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11111296/