<strong>一、需求原因<br></strong>在填写表单时需要实现如下效果<br><img alt="" src="http://files.jb51.net/file_images/article/201401/20140126095840.png"><br><strong>二、具体实现<br></strong><div class="codetitle"> <span><a style="CURSOR: pointer" data="14976" class="copybut" id="copybut14976" onclick="doCopy('code14976')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code14976"> <br><br><br><br><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <br><title>鼠标点击后无文字,挪开鼠标后有文字</title> <br><script language="JavaScript" src="../jQuery/jquery-1.7.1.min.js"></script><br><script type="text/javascript"><BR> $(function(){<BR> /*进入焦点时触发*/<BR> $("#account").focus(function(){<BR> varoldValue = $(this).val();<BR> if(oldValue == this.defaultValue){<BR> $(this).val("");<BR> }<BR> }); <BR> /*失去焦点时触发*/<BR> $("#account").blur(function(){<BR> alert("12");<BR> varoldValue = $(this).val();<BR> if(oldValue == ""){<BR> $(this).val(this.defaultValue);<BR> }<BR> });<BR> });<BR></script><br><br><br>帐号:<input id="account" name="account" type="text" value="请输入帐号"><br><br><br> </div>