设置文本框获取焦点后清空默认值,焦点移开后若值为空则显示默认值,否则显示修改的值

使用onblur和onfocus属性: 

<input type="text" value="默认值" onblur="if(this.value==''){this.value='默认值'}" onfocus="if(this.value=='默认值'){this.value=''}" />

  

原文地址:https://www.cnblogs.com/liuyueyingzi/p/3345762.html