jQuery實現登入提示

來源:互聯網
上載者:User

標籤:

實現效果:將滑鼠聚焦到郵箱地址文字框時,文字框 內的“請輸入郵箱地址”文字將被清除;

       若沒有輸入任何內容,滑鼠移除後郵箱地址文字框被還原。

 

 1 <!DOCTYPE html> 2 <html> 3 <head> 4     <meta charset="UTF-8"> 5     <title>註冊</title> 6     <!-- <link rel="stylesheet" href="css/default.css" type="text/css" /> --> 7      8     <script type="text/javascript" src="../scripts/jquery-1.7.2.js"></script> 9     <script type="text/javascript">10     $(function(){11         $("#mailaddress").focus(function(){12             var txt_val = $(this).val();13             if (txt_val == "請輸入郵箱地址") {14                 $(this).val("");15             }16         });17 18         $("#mailaddress").blur(function(){19             var txt_val = $(this).val();20             if (txt_val == "") {21                 $(this).val("請輸入郵箱地址");22             }23         });24         $("#password").focus(function(){25             var txt_val = $(this).val();26             if (txt_val == "請輸入郵箱密碼") {27                 $(this).val("");28             }29         });30 31         $("#password").blur(function(){32             var txt_val = $(this).val();33             if (txt_val == "") {34                 $(this).val("請輸入郵箱密碼");35             }36         });37 38 39     });40     </script>41 </head>42 <body>43      <input type="text" id="mailaddress" value="請輸入郵箱地址"/>   <br/><br/>44     <input type="text" id="password" value="請輸入郵箱密碼"/>  <br/><br/>45     <input type="button" value="登入"/>46 </body>47 </html>

 

 

 

 

 

jQuery實現登入提示

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.