<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','年/月/日');}});
更多专业前端知识,请上 【猿2048】www.mk2048.com