很简单的 onblur onfocus方法示例

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>

<input type='text' id='txt_q' name='q' class='SERACH' value='hello world'

onblur="(this.value=='')?this.value='hello world':this.value"

onfocus="if(this.value=='hello world'){this.value='';};this.select();"/>
<br/>
</body>
</html>

你可能感兴趣的:(focus)