1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 5 <title>jQuery+JavaScript 实现 table 的增加和减少</title> 6 <script language="javascript" src="jquery-1.7.1.min.js"></script> 7 </head> 8 <body> 9 <p><input type="text" value="请输入邮箱地址" id="email" id="email" /></p> 10 <p><input type="button" value="提交" /></p> 11 <script type="text/javascript"> 12 $("#email").focus(function(){ 13 var email_txt = $(this).val(); 14 if (email_txt == this.defaultValue) { 15 $(this).val(""); 16 } 17 }) 18 $("#email").blur(function(){ 19 var email_txt = $(this).val(); 20 if (email_txt == "") { 21 $(this).val(this.defaultValue); 22 } 23 }) 24 </script> 25 </body> 26 </html>