第一种:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
</head>
<body>
<input type="text" value="请输入..." id="phpzixue" />
<script language="JavaScript" type="text/javascript">
function addListener(element,e,fn){
if(element.addEventListener){
element.addEventListener(e,fn,false);
} else {
element.attachEvent("on" + e,fn);
}
}
var phpzixue = document.getElementById("phpzixue");
addListener(phpzixue,"click",function(){
phpzixue.value = "";
})
//addListener(phpzixue,"blur",function(){ //失去焦点时的动作
// phpzixue.value = "请输入...";
// })</script>
</body>
</html>第二种:
<input type="text" value="单击则选中!" onclick="this.select()">
onclick事件调用select()方法,选中自身
用onfocus="this.select()"也可,onfocus就是指自身被聚焦,这个跟onclick效果是一样的