解决默写浏览器中点击input输入框时,placeholder的值不消失的方法

html中,placeholder作为input的一个属性,起到了在输入框中占位并提示的作用。

但是有一些浏览器,如chrome,当鼠标点击输入框时,placeholder的值不消失,只有输入数据才消失,会使前端用户体验大打折扣。

看了很多大神的方法,写了长长的js,看着有点吃力,就想到了下面这种最傻的方法解决了这个问题。

html代码:

<input type="text" placeholder="请输入">

在其中只需加入两个简短的js即可:

<input type="text" placeholder="请输入" onfocus="this.placeholder=''" onblur="this.placeholder='请输入'">

 

posted on 2015-02-04 17:16  KKatherine  阅读(12325)  评论(1编辑  收藏  举报

导航