【发布时间】:2019-01-27 07:12:32
【问题描述】:
无法获取“输入字段的“最大”属性的今天日期值”,但可以在控制台中获取该值。
你们能帮我如何在输入字段中获取价值(即 max="2018-08-21")
var todayDate =
new Date().getFullYear() +
"-" +
("0" + (new Date().getMonth() + 1)).slice(-2) +
"-" +
("0" + new Date().getDate()).slice(-2);
console.log(todayDate, "here");
<div class="input-group">
<input type="date" max="todayDate" />
</div>
【问题讨论】:
-
你的Javascript应该在HTML之前
-
处理日期时应使用
momentjs。
标签: html angular typescript