<input type="date" class="form-control date-picker" id="date2" name="date" data-date-format="DD MMMM YYYY" [min]="" ngModel required placeholder="DOB">我正试图在没有Angular库的情况下淡出未来的日期。
发布于 2021-02-04 13:13:42
尝试使用:
const datepicker = document.getElementById('date');
const today = new Date();
let date = today.getDate() > 9 ? today.getDate() :
`0${today.getDate()}`;
let month = today.getMonth() > 9 ? today.getMonth() + 1 :
`0${today.getMonth() + 1}`;
let year = today.getFullYear();
datepicker.setAttribute('max', `${year}-${month}-${date}`);
console.log(datepicker);<input type="date" id="date" name="bday">
https://stackoverflow.com/questions/66039556
复制相似问题