手机端input[type=date]的placeholder不起作用
生活随笔
收集整理的這篇文章主要介紹了
手机端input[type=date]的placeholder不起作用
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
<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>
更多專業(yè)前端知識(shí),請(qǐng)上 【猿2048】www.mk2048.com
css:
input[type="date"]:before{content: attr(placeholder);color:#ccc; }用戶選了日期以后我們模擬的默認(rèn)文字還在,所以在用戶選擇的時(shí)候就刪除此屬性,之后需要的話再添加回來。
js:
$('.text_date').focus(function(){$(this).removeAttr('placeholder');});$('.text_date').blur(function(){if(this.value == ''){$(this).attr('placeholder','年/月/日');}});?
更多專業(yè)前端知識(shí),請(qǐng)上 【猿2048】www.mk2048.com
總結(jié)
以上是生活随笔為你收集整理的手机端input[type=date]的placeholder不起作用的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: XML文档的简易增删查改
- 下一篇: Iframe父页面与子页面之间的相互调用