主要是文本框获得焦点事件通过onfocus事件来监听
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>成为焦点时清楚文本框内容</title>
<script>
function clearText(myText){
myText.value='';
}
</script>
</head>
<body>
<!-- 定义文本框 -->
请输入<input type="text" value="" id="myText" onfocus="clearText(this)" /><br /><br />
</body>
</html>