在Chrome中日期类型的输入删除占位符 [英] Remove placeholder from date type input in chrome

查看:352
本文介绍了在Chrome中日期类型的输入删除占位符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下输入:

<input class="AccordionLeft" id="operationDate" name="OperationDate" type="date" value="">

这显示的日期格式作为默认占位符。我想删除此占位符,只是有一个空的输入字段。

This shows the date format as a default placeholder. I would like to remove this placeholder and just have an empty input field.

如果我这样做:

`$('#operationDate').val('@DateTime.Now.ToString("yyyy-MM-dd")');`

我得到今天`日期作为占位符,但如果我用这个:

I get today`s date as the placeholder, but if I use this:

$('#operationDate').val('');

我得到这样占位符DD-MM-YYYY
可占位符被删除entirly?我看到有关更改日期格式几个职位,但都没有找到有关删除占位符completley。

I get the placeholder like dd-mm-yyyy. Can the placeholder be removed entirly? I have seen several posts about changing the date format, but have found none about removing the placeholder completley.

推荐答案

您可以隐藏在下面的样式规则的格式占位符:

You can hide the format placeholder with the following style rule:

<style>
::-webkit-datetime-edit-year-field:not([aria-valuenow]),
::-webkit-datetime-edit-month-field:not([aria-valuenow]),
::-webkit-datetime-edit-day-field:not([aria-valuenow]) {
    color: transparent;
}
</style>
<input type=date>

这篇关于在Chrome中日期类型的输入删除占位符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆