如何添加占位符< input type =& quot; datetime-local"& gt;场地? [英] How to add placeholder &lt;input type=&quot;datetime-local&quot;&gt; field?
本文介绍了如何添加占位符< input type =& quot; datetime-local"& gt;场地?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在尝试在input type ='datetime-local'字段中添加占位符,但这根本不起作用.使用css解决问题,但仍然无法完成:(
I've been trying to add placeholder in input type='datetime-local' field but it doesn't work at all. Use css for solving the issue but still unable to do it :(
input[type="datetime-local"]:before{
content: 'Selecteer Datum';
color: #000;
text-align: center;
width:100%;
}
input[type="datetime-local"]:active:before, input[type="datetime-local"]:hover:before, input[type="datetime-local"]:visited:before, input[type="datetime-local"]:focus:before{
content: '';
width: 100%;
}
<form action="" method="post">
<div class="datetime">
<input type="datetime-local" >
</div>
</form>
推荐答案
这有点奇怪,将输入类型更改为 text
,然后将其转换为 datetime-local
使用下面的javascript进行关注.
This is kind of a wonky idea, change the input type to text
, then it will convert to datetime-local
on focus using the below javascript.
<input type="text" id="txtbox" placeholder="Heya">
<script>
var dtt = document.getElementById('txtbox')
dtt.onfocus = function (event) {
this.type = 'datetime-local';
this.focus();
}
</script>
这篇关于如何添加占位符< input type =& quot; datetime-local"& gt;场地?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文