我在项目中包含了jquery-ui.css,jquery-ui.js和jquery-3.2.1.min.js文件,但仍然出现以下错误
"$("#ClaimExpenseDate_" + RowCount).datepicker" is not a function
$("#ClaimExpenseDate_" + RowCount).datepicker({
maxDate: maxDate,
dateFormat: "dd/mm/yy"
});
答案 0 :(得分:0)
也许此时jQuery尚未完全加载,您确定之前未调用过代码吗?也许该元素不存在或未加载。
您可以尝试使用这种语法吗?
$( function() {
const elem = $("#ClaimExpenseDate_" + RowCount);
console.log('Elem exists?', elem);
console.log('datepicker exists?', elem.datepicker);
elem.datepicker({
maxDate: maxDate,
dateFormat: "dd/mm/yy"
});
});
还有另一个奇怪的错误