<html>
<head>
<title>给文本框添加灰色提示文字</title>
<meta http-equiv="content-Type" content="text/html;charset=gb2312">
</head>
<body>
<!--把下面代码加到<body>与</body>之间-->
</html>
<head>
<title>给文本框添加灰色提示文字</title>
<meta http-equiv="content-Type" content="text/html;charset=gb2312">
</head>
<body>
<!--把下面代码加到<body>与</body>之间-->
<input type="text" id="key" name="key" value="请输入关键词"
onFocus="if(value==defaultValue){this.value='';this.style.color='#000'}" //焦点在文本上时,如果没有输入文字,条件为true,文本框置空,等待输入。
onBlur="if(!value){this.value=defaultValue;this.style.color='#999'}" //焦点移走时,如果文字有改变,条件为false;未有改变时,条件为true,文本设为原来的值。
style="color:#999999" />
</body></html>