手机端input[type=date]的placeholder不起作用

     <div class="input clearfix">
            <label class="fl">起始日期</label>
            <input class="fl text_date" type="date" name=""   value="" placeholder="年/月/日" />
        </div>
        <div class="input clearfix">
            <label class="fl">终止日期</label>
            <input class="fl text_date" type="date" name=""  value="" placeholder="年/月/日" />
        </div>

css:

input[type="date"]:before{
    content: attr(placeholder);
    color:#ccc;
}

用户选了日期以后我们模拟的默认文字还在,所以在用户选择的时候就删除此属性,之后需要的话再添加回来。

js:

$('.text_date').focus(function(){
        $(this).removeAttr('placeholder');
    });
    $('.text_date').blur(function(){
        if(this.value == ''){
            $(this).attr('placeholder','年/月/日');
        }
    });

 

posted @ 2017-10-31 17:13  Jade_g  阅读(424)  评论(0编辑  收藏  举报