<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','年/月/日');
        }
    });

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-03
  • 2022-12-23
  • 2022-12-23
  • 2021-07-09
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-28
  • 2021-10-05
  • 2021-11-12
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案