Zee*_*ius 6 html javascript css forms
我一直在尝试在 input type='datetime-local' 字段中添加占位符,但它根本不起作用。使用css解决问题但仍然无法做到:(
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%;
}Run Code Online (Sandbox Code Playgroud)
<form action="" method="post">
<div class="datetime">
<input type="datetime-local" >
</div>
</form>
Run Code Online (Sandbox Code Playgroud)
这是一种奇怪的想法,将输入类型更改为text,然后它将datetime-local使用下面的 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>
Run Code Online (Sandbox Code Playgroud)