如何在 HTML5 中为输入类型=“date”字段展示佔位符? 如何解决?


要显示它,请使用以下内容 −

<input placeholder = "Date" class = "textbox-n" type = "text" onfocus = "(this.type = 'date')"  id = "date">

您还可以使用 CSS −

input[type="date"]::before{
   color: #ffffff;
   content: attr(placeholder) ": ";
}
input[type="date"]:focus::before {
   content: "" !important;
}

更新时间: 04-3-2020

4K+ 阅读量

开启你的职业生涯

完成课程获得认证

开始
广告
© . All rights reserved.