使用脚本来阻止日历中的某些日期。尝试按名称阻止日期(data-picker=“2021-7-8”)。在日历中,他们的名字是以yyyy-mm-dd的格式完成的,这在iOS中是不支持的。我无法将此数据转换为iOS格式YYYY/MM/DD,否则将找不到它。
<td class="current-month" data-picker="2021-7-8">8</td>我的代码:
let findDate = setAttrDate.getFullYear()+'-'+(setAttrDate.getMonth()+1)+'-'+setAttrDate.getDate()
$('.cal-month td[data-picker="'+findDate+'"]').addClass('pastDay');发布于 2021-07-04 00:38:34
这个问题是不可理解的。setAttrDate是从哪里来的,它是包含NaN的对象吗?iOS的问题在哪里?
这是可行的
// from dashes:
const d = "2021-7-2";
const [yyyy,mm,dd] = d.split("-")
const setAttrDate = new Date(yyyy,mm-1,dd,15,0,0); // normalise at 15:00
console.log(setAttrDate)
let findDate = `${setAttrDate.getFullYear()}-${setAttrDate.getMonth()+1}-${setAttrDate.getDate()}`;
console.log(findDate)
$('.cal-month td[data-picker="'+findDate+'"]').addClass('pastDay');.pastDay { color:red }<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table class="cal-month"><tr><td data-picker="2021-7-2">02</td></tr></table>
https://stackoverflow.com/questions/68238026
复制相似问题