JSP text鼠标点击内容清空

用户名输入的text
鼠标点击TEXT TEXT的内容清空怎么写 有比较简洁的吗

第1个回答  2009-04-18
那是用JavaScript:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>测试清空</title>
<script type="text/javascript">
function clearText(obj) {
if(!obj) return;
if(!obj.value) return;
obj.value = "";
}
</script>
</head>
<body>
<h1>请输入用户名</h1>
<hr />
<form action="" method="get">
用户名:<input name="username" type="text" onfocus="clearText(this)" />
</form>
</body>
</html>
第2个回答  2009-04-18
你这个问题。。。
<input type="text" value="" onclick="javascript:this.value='';">本回答被提问者采纳
相似回答