html5中新增的input时间,在pc端有提示年月日或者周,但在touch中没有任何提示为空白,placeholder默认不支持时间、搜索和数字的input。
html :
<input class="TestTime" type="date" value="" placeholder="请输入日期">
css:
.TestTime{
-webkit-appearance: none;width:200px;height:30px;font-size:15px;border:1px solid #ddd;
}
.TestTime:before{
content: attr(placeholder);
color:#999;
}
js:
//时间控件默认提示
$(".TestTime").focus(function(){
$(this).removeAttr("placeholder");
});
$(".TestTime").blur(function(){
if($(this).val() == "")
$(this).attr("placeholder","请输入日期");
});