聚焦时清空字段

Avatar of Chris Coyier
Chris Coyier
<input type="text" onfocus="if(this.value == 'value') { this.value = ''; }" value="value" />

将“value”替换为默认值。如果字段被选中,默认值将消失。如果用户之前更改了字段值,则该值将保持不变。

或者,使用 onfocus=”this.value=”;” 始终清空字段。