jQuery实现登录提示
生活随笔
收集整理的這篇文章主要介紹了
jQuery实现登录提示
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
實(shí)現(xiàn)效果:將鼠標(biāo)聚焦到郵箱地址文本框時(shí),文本框 內(nèi)的“請(qǐng)輸入郵箱地址”文字將被清除;
??若沒有輸入任何內(nèi)容,鼠標(biāo)移除后郵箱地址文本框被還原。
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="UTF-8"> 5 <title>注冊(cè)</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 == "請(qǐng)輸入郵箱地址") { 14 $(this).val(""); 15 } 16 }); 17 18 $("#mailaddress").blur(function(){ 19 var txt_val = $(this).val(); 20 if (txt_val == "") { 21 $(this).val("請(qǐng)輸入郵箱地址"); 22 } 23 }); 24 $("#password").focus(function(){ 25 var txt_val = $(this).val(); 26 if (txt_val == "請(qǐng)輸入郵箱密碼") { 27 $(this).val(""); 28 } 29 }); 30 31 $("#password").blur(function(){ 32 var txt_val = $(this).val(); 33 if (txt_val == "") { 34 $(this).val("請(qǐng)輸入郵箱密碼"); 35 } 36 }); 37 38 39 }); 40 </script> 41 </head> 42 <body> 43 <input type="text" id="mailaddress" value="請(qǐng)輸入郵箱地址"/> <br/><br/> 44 <input type="text" id="password" value="請(qǐng)輸入郵箱密碼"/> <br/><br/> 45 <input type="button" value="登錄"/> 46 </body> 47 </html>
?
?
?
?
轉(zhuǎn)載于:https://www.cnblogs.com/noaman/p/5954622.html
總結(jié)
以上是生活随笔為你收集整理的jQuery实现登录提示的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: android之隐示意图跳转启动另一个a
- 下一篇: 电脑硬盘修复方法