beforeshowday 选项在 datetimepicker 中不起作用我试过下面的代码。我尝试在 beforeshowday 函数中添加简单的警报,但它不起作用
$(document).ready(function(){
const current = new Date();
const prior = new Date().setDate(current.getDate() - 30);
var active_dates = ["03/02/2023","03/03/2023"];
$("#purchase_date").datetimepicker({
format: 'mm/dd/yyyy hh:ii:ss',
autoclose: true,
todayBtn: true,
todayHighlight: true,
//startDate: new Date(prior),
//endDate: '+0d',
showOtherMonths: true,
pickerPosition: "bottom-left",
beforeShowDay: function(date){alert();
var d = date;
var curr_date = d.getDate();
var curr_month = d.getMonth() + 1; //Months are zero based
var curr_year = d.getFullYear();
var formattedDate = curr_month + "/" + curr_date + "/" + curr_year
if ($.inArray(formattedDate, active_dates) != -1){
return {
classes: 'activeClass'
};
}
return;
},
});
}); ```
i added code and it's not working