jQuery UI 日期选择器 onSelectAfter
jQuery UI datepicker onSelectAfter
如何在选择日期后执行功能? onSelect 似乎之前触发过。我想检查所选日期是否有特定的 class.
onSelect: function (dateText, inst) {
if($('.ui-state-active').parent().hasClass('express')){
console.log('express click');
}else{
console.log('no express click');
}
}
这行不通。感谢您的任何提示。
请试试这个:
onSelect: function (dateText, inst) {
var day = inst.selectedDay,
mon = inst.selectedMonth,
year = inst.selectedYear;
var el = $(inst.dpDiv).find('[data-year="'+year+'"][data-month="'+mon+'"]').filter(function() {
return $(this).find('a').text().trim() == day;
});
if ( el.parent().hasClass('express')){
console.log('express click');
}else{
console.log('no express click');
}
}
如何在选择日期后执行功能? onSelect 似乎之前触发过。我想检查所选日期是否有特定的 class.
onSelect: function (dateText, inst) {
if($('.ui-state-active').parent().hasClass('express')){
console.log('express click');
}else{
console.log('no express click');
}
}
这行不通。感谢您的任何提示。
请试试这个:
onSelect: function (dateText, inst) {
var day = inst.selectedDay,
mon = inst.selectedMonth,
year = inst.selectedYear;
var el = $(inst.dpDiv).find('[data-year="'+year+'"][data-month="'+mon+'"]').filter(function() {
return $(this).find('a').text().trim() == day;
});
if ( el.parent().hasClass('express')){
console.log('express click');
}else{
console.log('no express click');
}
}