input type="date" 提示不显示

//CSS
input[type="date"]:before{
    color:#A9A9A9;content:attr(placeholder);
}
input[type="date"].full:before {
    color:black;content:""!important;
}
//HTML
<input type="date" placeholder="请选择日期">
//JS
//input type=date 日期的提示清除
$("input[type='date']").on("input",function(){
        if($(this).val().length>0){
                $(this).addClass("full");
        }else{
                $(this).removeClass("full");
        }
});

需要引用jquery 不然提示无法清除

猜你喜欢

转载自blog.csdn.net/qq_39816586/article/details/82221413