<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gbk"> <title>test</title> <script type="text/javascript" src="js/jquery-1.3.2.js"></script> </head> <body> <form> <input type="text" value="请输入你的密码" οnfοcus="psw(this)" οnblur="txt(this)" /> <input type="text" value="请输入你的邮箱" οnfοcus="hide(this)" οnblur="show(this)" /> </form> <script type="text/javascript"> function psw(el){ if(el.value=="请输入你的密码"){ el.value=""; el.type="password"; } } function txt(el){ if(!el.value){ el.value="请输入你的密码"; el.type="text"; } } function hide(el){ if(el.value=="请输入你的邮箱"){ el.value=""; } } function show(el){ if(!el.value){ el.value="请输入你的邮箱"; } } </script> </body> </html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gbk"> <title>test</title> <script type="text/javascript" src="js/jquery-1.3.2.js"></script> </head> <body> <form> <input type="text" value="请输入你的密码" /><input type="password" style="display:none" /> </form> <script type="text/javascript"> $("form input[type=text]").focus(function(){ $(this).hide(); $("form input[type=password]").show().focus(); }) $("form input[type=password]").blur(function(){ if($(this).val()==""){ $(this).hide(); $("form input[type=text]").show(); } }) </script> </body> </html>
转载于:https://blog.51cto.com/linchqd/1320726