当前位置: 代码迷 >> Web前端 >> 点击input默许值消失
  详细解决方案

点击input默许值消失

热度:476   发布时间:2013-11-08 17:52:01.0
点击input默认值消失
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>index.html</title>

	</head>

	<body>

		<input type="text" id="test" value="xxx@xxx.com" style="color: gray;"
			onkeypress="this.style.color='black';" />
			
			
		<hr />
		点击input默认值消失
		<br />

		input:
		<br />
		<input name="textfield" type="text" value="点击添入标题" style="color: gray;"
			onfocus="if (value =='点击添入标题'){value =''}"
			onblur="if (value ==''){value='点击添入标题'}" />
		<br />
		textarea:
		<br />
		<textarea name="textarea" cols="80" rows="17"
			onfocus="if(value=='正文:'){value=''}"
			onblur="if (value ==''){value='正文:'}"></textarea>

	</body>
</html>

?

  相关解决方案