JQuery實現密碼的顯示與隱藏
阿新 • • 發佈:2019-01-29
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>密碼的來回顯示</title> <script type="application/javascript" src="../frameworks/jquery-2.1.4/jquery-2.1.4.js"></script> <script type="application/javascript"> $(function(){ $("#showPass").on("mouseover",function(){ $("#pass").prop("type","text"); }); $("#showPass").on("mouseout",function(){ $("#pass").prop("type","password"); }); }); </script> </head> <body> <form action="#"> <input id="pass" type="password" name="password"> <span id="showPass">顯示密碼</span> </form> </body> </html>