<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>XXX</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <script language="JavaScript" src="js/jquery-1.3.1.js"></script> <style type="text/css"> div,span{ width: 140px; height: 140px; margin: 20px; background: #9999CC; border: #000 1px solid; float:left; font-size: 17px; font-family:Roman; } div.mini{ width: 30px; height: 30px; background: #CC66FF; border: #000 1px solid; font-size: 12px; font-family:Roman; } </style> <!--引入jquery的js庫--> </head> <body> <!--value 就是默認值 能夠經過 this.defaultValue來訪問--> <input type="text" value="用戶郵箱/手機號/用戶名" id="b1"/><br> <input type="password" value="" id="b2"/><br> <input type="button" value="登錄" id="b3"/> <br> </body> <script language="JavaScript"> $(document).ready(function (){ $("#b1").focus(function(){ if($(this).val()==this.defaultValue){ $(this).val(""); } }) $("#b1").blur(function(){ if($(this).val()==""){ $(this).val(this.defaultValue); } }) }); </script> </html>