<div class="htmlarea"> <textarea id="runcode4752"> <meta http-equiv="Content-Type" content="text/html; charsetGB2312"> <title>文本框点击时文字消失,失去焦点时文字出现 </title> <input type="text" value="请输入您的姓名" id="myinput"> <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 myinput = document.getElementById("myinput"); addListener(myinput,"click",function(){ myinput.value = ""; }) addListener(myinput,"blur",function(){ myinput.value = "请输入您的姓名"; }) </script> </textarea><br><input onclick="runEx('runcode4752')" type="button" value="运行代码"> <input onclick="doCopy('runcode4752')" type="button" value="复制代码"> <input onclick="doSave(runcode4752)" type="button" value="保存代码">[Ctrl+A 全选 注:<a href="http://www.jb51.net/article/23421.htm" title="查看具体详情" target="_blank">如需引入外部Js需刷新才能执行</a>]</div>